Please help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prkinlotpmpin
    New Member
    • Oct 2006
    • 6

    #1

    Please help

    I am in a beginers visual basic class and need help with a program. it is a basic program and the trouble i have is that after i export the fields into notepad, i need the fields to be cleared. i have no idea how to get the fields cleared!!!! any possible information would be much appreciated. i have searched everywhere and can not find an answer. thanks in advance...

    heres my program so far....

    'Team 14
    'This program accepts name and address information from the user.
    Option Explicit
    Private intFileNumber As Integer

    Private Sub cmdEnter_Click( )
    Dim strName As String * 30
    Dim strAddress As String * 35
    Dim strCity As String * 25
    Dim strState As String * 2
    Dim strZip As String * 5
    Dim strAccount As String * 6
    Dim strBalance As String * 7
    Dim curBalance As Currency
    Dim lngBalance As Long
    strName = txtName.Text
    strAddress = txtAddress.Text
    strCity = txtCity.Text
    strState = txtState.Text
    strZip = txtZip.Text
    strAccount = txtAccount.Text
    curBalance = CCur(txtBalance .Text)
    lngBalance = curBalance * 100
    strBalance = (7)
    RSet strBalance = CStr(lngBalance )
    strBalance = Replace(strBala nce, " ", "0")
    Print #intFileNumber, strName; strAddress; strCity; strState; strZip; strAccount; strBalance
    End Sub

    Private Sub cmdExit_Click()
    Unload Me
    End Sub

    Private Sub Form_Load()
    Dim strFileName As String
    intFileNumber = FreeFile
    strFileName = App.Path & "\Something.txt "
    Open strFileName For Output As #intFileNumber
    End Sub

    Private Sub Form_Unload(Can cel As Integer)
    Close #intFileNumber
    End Sub
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    I know little about Visual Basic but I reckon

    txtName.Text = ""

    may do it

    Comment

    • Seith
      New Member
      • Oct 2006
      • 16

      #3
      Yeh, he's right although you don't need .text becuase it assumes that's what you mean:


      text_box_name = ""

      This will replace the textbox with [ ]

      And so far your program looks great :}

      Comment

      • Seith
        New Member
        • Oct 2006
        • 16

        #4
        Originally posted by Seith
        Yeh, he's right although you don't need .text becuase it assumes that's what you mean:


        text_box_name = ""

        This will replace the textbox with [ ]

        And so far your program looks great :}
        No edits snarl

        Okay, so I loaded up your application - but it doesn't acutally write to something.txt? Just in case you didn't know?

        Comment

        • Seith
          New Member
          • Oct 2006
          • 16

          #5
          Stupid 5 Minute Edit thing!

          Okay, I fixed your program for you if you're interested:

          Code:
          Private Sub cmdEnter_Click()
              Dim intFileNumber As Integer
              Dim strFileName As String
              Dim strName As String * 30
              Dim strAddress As String * 35
              Dim strCity As String * 25
              Dim strState As String * 2
              Dim strZip As String * 5
              Dim strAccount As String * 6
              Dim strBalance As String * 7
              Dim curBalance As Currency
              Dim lngBalance As Long
              
              Open strFileName For Output As #intFileNumber
              
                  intFileNumber = FreeFile
                  strFileName = App.Path & "\Something.txt"
                  strName = txtName.Text
                  strAddress = txtAddress.Text
                  strCity = txtCity.Text
                  strState = txtState.Text
                  strZip = txtZip.Text
                  strAccount = txtAccount.Text
                  
                  curBalance = CCur(txtBalance.Text)
                  lngBalance = curBalance * 100
                  strBalance = (7)
                  RSet strBalance = CStr(lngBalance)
                  strBalance = Replace(strBalance, " ", "0")
              
              Print #intFileNumber, strName & vbCrLf & strAddress & vbCrLf & strCity & vbCrLf & strState & vbCrLf & strZip & vbCrLf & strAccount & vbCrLf & strBalance
              Close #intFileNumber
          End Sub
          Changes:
          All variables are set in the command button.
          I added vbCrLf into the Print section, this means it will put a new line for each entry - vbCrLf means RETURN key.
          You didn't set 2 of the variables correctly, you missed Dim for some reason?
          The command button OPENS EDITS then CLOSES the document, otherwise it'll try to re-open an open file! If you want to use an if statement here, do so!

          Now, after Close #intFileNumber you want to write:
          Code:
                  txtName.Text = ""
                  txtAddress.Text = ""
                  txtCity.Text = ""
                  txtState.Text = ""
                  txtZip.Text = ""
                  txtAccount.Text = ""
          To reset all the fields

          Have fun, more questions just reply!

          Comment

          • prkinlotpmpin
            New Member
            • Oct 2006
            • 6

            #6
            Thank you, every post has been very helpful. I appreciate everybody's help!!!

            Comment

            Working...