Results 1 to 2 of 2

Thread: Saving a set number of taxt boxes that might be empty

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2008
    Posts
    38

    Saving a set number of taxt boxes that might be empty

    (Sorry for the mistype in the title, should have been 'text', not taxt)
    I'm trying to save information from text boxes to a text file that can be loaded later. The problem is that I need to save a 'spot' in the file, in case a text box in the middle gets filled later. Until this gets fixed, I get runtime error 5: Invalid procedure call or argument.

    Code:
    Private Sub mnuFileSave_Click()
        'Saves the customer's information
        
        '###Finished, but untested
        
        'Check if file exists. If so, then overwrite. If not, make the file.
        If Dir(App.Path & "\Saved" & "\" & txtName.Text & " " & txtCar.Text & " " & txtDate.Text & ".txt") <> "" Then
            Open App.Path & "\Saved" & "\" & txtName.Text & " " & txtCar.Text & " " & txtDate.Text & ".txt" For Output As #1
        Else: Open App.Path & "\Saved" & "\" & txtName.Text & " " & txtCar.Text & " " & txtDate.Text & ".txt" For Append As #1
        End If
        
        Write #1, txtName.Text, txtAddress.Text, txtDate.Text, txtNumber.Text, txtCar.Text
        Dim cnt As Integer
        For cnt = 0 To 13
            
    Error here Code:
    1. Write #1, Val(txtPartNo(cnt).Text), txtPartNum(cnt).Text, txtPartName(cnt).Text, Val(FormatNumber(txtPartPrice(cnt).Text, 2))
    Next cnt Write #1, Val(FormatNumber(txtPartsTotal(0).Text, 2)) For cnt = 0 To 3 Write #1, txtEst(cnt).Text, Val(FormatNumber(txtEstimate(cnt).Text, 2)) Next cnt Write #1, Val(FormatNumber(txtEstimateTotal.Text, 2)) For cnt = 0 To 9 Write #1, txtLabor(cnt).Text, Val(FormatNumber(txtLaborCost(cnt).Text, 2)) Next cnt Write #1, Val(FormatNumber(txtLaborTotal.Text)), Val(FormatNumber(txtPartsTotal(1).Text)), Val(FormatNumber(txtTotal.Text)) Close #1 End Sub
    Last edited by Levells; Oct 6th, 2009 at 02:56 PM.
    I use VB 6. I've been programming since September 2008.

  2. #2
    Lively Member Hojo's Avatar
    Join Date
    Jul 2005
    Location
    Brisbane, Australia
    Posts
    119

    Re: Saving a set number of taxt boxes that might be empty

    I think you will need to Val the txtPartPrice(cnt).text before the formatNumber function.

    IE,

    Code:
    Formatnumber(Val(txtPartPrice(cnt).text),2)
    Cheers,

    Hojo
    Despite body and mind, my youth will never die!

    Everytime I learn something new it pushes some old stuff out of my brain!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width