Tim^^BOB
2003-10-04 20:04:10 UTC
I want to make an application that holds phone numbers. It has a
textbox, a listbox and a commandbutton. All i want to do is whenever
you press the command button, the text in the textbox is added to the
listbox and saved to a file (eg. "mynumbers.txt). Also all the numbers
need to be loaded when the application is started. I dont understand
why my code wont work!! This is what I have now:
'command button code
Private Sub AddPhone_Click()
For I = 1 To 10
If PhoneNumbers(I) = "" Then
A = I
End If
Next I
If A = "" Then
MsgBox "CANNOT ADD MORE NUMBERS"
Exit Sub
Else
PhoneNumbers(A) = NewPhone.Text
PhoneList.AddItem PhoneNumbers(A)
End If
Open "mynumbers.txt" For Random As #1
For I = 1 To 10
Put #1, I, PhoneNumbers(I)
Next I
Close #1
End Sub
'form load codePrivate Sub Form_Load()
Open "mynumbers.txt" For Random As #1
For I = 1 To 10
PhoneList.AddItem PhoneNumbers(I)
Next I
Close #1
End Sub
Thank you in advance everyone.
textbox, a listbox and a commandbutton. All i want to do is whenever
you press the command button, the text in the textbox is added to the
listbox and saved to a file (eg. "mynumbers.txt). Also all the numbers
need to be loaded when the application is started. I dont understand
why my code wont work!! This is what I have now:
'command button code
Private Sub AddPhone_Click()
For I = 1 To 10
If PhoneNumbers(I) = "" Then
A = I
End If
Next I
If A = "" Then
MsgBox "CANNOT ADD MORE NUMBERS"
Exit Sub
Else
PhoneNumbers(A) = NewPhone.Text
PhoneList.AddItem PhoneNumbers(A)
End If
Open "mynumbers.txt" For Random As #1
For I = 1 To 10
Put #1, I, PhoneNumbers(I)
Next I
Close #1
End Sub
'form load codePrivate Sub Form_Load()
Open "mynumbers.txt" For Random As #1
For I = 1 To 10
PhoneList.AddItem PhoneNumbers(I)
Next I
Close #1
End Sub
Thank you in advance everyone.