Hi all,
New to this site asd VB6 AAAAAAA i'm trying my best.
Anyway here goes need to store names and numbers names in lstbox number in an array. select the name from the lstbox and display the number in a lbl.
here's the code so far can someone please push me in the right direction, as i say new to vb and can't see where i'm going wrong. :eek:
'***force variable declaration
Option Explicit
'***declare global variables
Dim addname As String
Dim numbers(20) As String
Dim newnumber As String
Dim reply As Integer
Private Sub cmdAdd_Click()
If txtEname = "" Or IsNumeric(txtEname) = True Then
reply = MsgBox("Please enter Name", vbOKOnly + vbInformation, "NAME")
Else
If txtTnum.Text = "" Or IsNumeric(txtTnum.Text) = False Then
reply = MsgBox("Please enter number", vbOKOnly + vbInformation, "NUMBER")
Else
'***assign variables
addname = txtEname.Text
lstNames.AddItem addname '***adds name to list box
numbers(lstNames.ListIndex) = txtTnum.Text
lstNames = lstNames + 1
End If
End If
End Sub
Private Sub cmdClear_Click()
lblNum.Caption = ""
End Sub
Private Sub cmdDisplay_Click()
numbers(lstNames.ListIndex) = newnumber
lblNum.Caption = newnumber
End Sub
Private Sub cmdExit_Click()
'***declare local variables
Dim temp As Integer
'*** does the user want to exit program
temp = MsgBox("Are you sure you would like to exit the program", vbYesNo + vbExclamation, _
"QUIT?")
If temp = vbYes Then
End '***if yes quit program
Else '***else do nothing
End If
End Sub
The line i've highlighted is the line it debugs.
thanks in advance