basic HELP! txt file saving and writing

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • currysauce
    New Member
    • Oct 2006
    • 5

    #1

    basic HELP! txt file saving and writing

    Hi, I am new to VB and I am having problems.
    I need to create a program, that will allow a user to input a number say 1000.
    The program will then creat a txt file called "mypdbs" inside the file, will be the numbers from 0-1000 (one number on ever line) with .pdb after each number ex.

    0.pdb
    1.pdb
    2.pdb

    I would appreciate the help, it is hurting my head.
    thanks
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by currysauce
    Hi, I am new to VB and I am having problems.
    I need to create a program, that will allow a user to input a number say 1000.
    The program will then creat a txt file called "mypdbs" inside the file, will be the numbers from 0-1000 (one number on ever line) with .pdb after each number ex.

    0.pdb
    1.pdb
    2.pdb

    I would appreciate the help, it is hurting my head.
    thanks
    I'll leave it to you how to get the input - that is very version-specific. But here's a quick and simple chunk of code to write out your results...
    Code:
      Dim I As Long, J As Long
      ' Get you input in J, then...
      Open "mypdbs.txt" For Output Access Write Lock Write As #1
      For I = 0 To J
        Print #1, Format$(I); ".pdb"
      Next
      Close

    Comment

    • currysauce
      New Member
      • Oct 2006
      • 5

      #3
      Originally posted by Killer42
      I'll leave it to you how to get the input - that is very version-specific. But here's a quick and simple chunk of code to write out your results...
      Code:
        Dim I As Long, J As Long
        ' Get you input in J, then...
        Open "mypdbs.txt" For Output Access Write Lock Write As #1
        For I = 0 To J
          Print #1, Format$(I); ".pdb"
        Next
        Close

      do you know how to do the input using visual basic.net

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Originally posted by currysauce
        do you know how to do the input using visual basic.net
        No, sorry. I'm only familiar with VB6, not the .Net version. Also, that will depend on what sort of interface you are dealing with. For instance, in VB6 the InputBox() function is probably the simplest way to prompt the user to input a value, but also a very ugly way.

        Comment

        • currysauce
          New Member
          • Oct 2006
          • 5

          #5
          Originally posted by Killer42
          No, sorry. I'm only familiar with VB6, not the .Net version. Also, that will depend on what sort of interface you are dealing with. For instance, in VB6 the InputBox() function is probably the simplest way to prompt the user to input a value, but also a very ugly way.
          Hi, i dont have vb6, is there anyway you could create that script for me in an .exe? and send it?

          Comment

          • Killer42
            Recognized Expert Expert
            • Oct 2006
            • 8429

            #6
            Originally posted by currysauce
            Hi, i dont have vb6, is there anyway you could create that script for me in an .exe? and send it?
            Well, I created an exe - it was about 30 seconds work. But...
            • I don't know your e-mail address
            • thescripts says you have elected not to receive e-mails
            • The "Private Message" function doesn't appear to allow attachments.

            Any suggestions?

            If you look up information on converting VB6 to VB.Net, or just online help for .Net, you should be able to convert the code easily enough. Here is the entire listing...
            Code:
            Option Explicit
            DefLng A-Z
            
            Public Sub Main()
              Dim I As Long, J As Long, s As String
              s = InputBox("Enter the limit")
              If s = Empty Then End
              If s = "." Or s = "" Or Val(s) <= 0 Then End
              J = Val(s)
              Open "mypdbs.txt" For Output Access Write Lock Write As #1
              For I = 0 To J
                Print #1, Format$(I); ".pdb"
              Next
              Close
            End Sub

            Comment

            • currysauce
              New Member
              • Oct 2006
              • 5

              #7
              Originally posted by Killer42
              Well, I created an exe - it was about 30 seconds work. But...
              • I don't know your e-mail address
              • thescripts says you have elected not to receive e-mails
              • The "Private Message" function doesn't appear to allow attachments.

              Any suggestions?

              If you look up information on converting VB6 to VB.Net, or just online help for .Net, you should be able to convert the code easily enough. Here is the entire listing...
              Code:
              Option Explicit
              DefLng A-Z
              
              Public Sub Main()
                Dim I As Long, J As Long, s As String
                s = InputBox("Enter the limit")
                If s = Empty Then End
                If s = "." Or s = "" Or Val(s) <= 0 Then End
                J = Val(s)
                Open "mypdbs.txt" For Output Access Write Lock Write As #1
                For I = 0 To J
                  Print #1, Format$(I); ".pdb"
                Next
                Close
              End Sub
              Hi, my email is [removed] , can you please send..thanks.

              Comment

              Working...