 |
| View previous topic :: View next topic |
| Author |
Message |
timmy Newbie
Joined: 08 Dec 2003 Posts: 5
|
Posted: Dec 11th, 2003 05:55 PM Post subject: input box and list trouble |
|
|
I need to display an input box, allowing the user to enter any number from 1-99. Every time they enter a valid number, it needs to be added into a list. As soon as they enter the same number twice, the input box needs to go away, and the list needs to show all of the numbers that were entered, before the duplicate. For some reason I cannot get my loop to work, and can't figure out why. Any help would be greatly appreciate. Below is my code.
Private Sub Form_Load()
'Displays an input box asking for numbers
'Show list after duplicate number is entered
intcount = 0
Do
intnumber = InputBox("Please enter a number between 1 and 99.", "Enter A Number")
If intnumber >= 1 And intnumber <= 99 Then
lstnumbers.AddItem intnumber
If intnumber <> intnumber Then
lstnumbers.AddItem intnumber
intcount = intcount + 1
End If
Else
MsgBox "Please enter a number from 1-99", vbOKOnly, "Invalid Number"
End If
Loop Until intnumber = intnumber
If intnumber = intnumber Then
lblduplicate.Caption = "Duplicate after " & intcount & " numbers."
End If
End Sub |
|
| Back to top |
|
Dragona Newbie
Joined: 11 Dec 2003 Posts: 7
|
Posted: Dec 12th, 2003 04:23 AM Post subject: |
|
|
hmm his wont entirely answer your question but i recently used a pice of code in a lotto program i made, which means no numbers below 1 and above 49 no alpha chars or anything
| Code: |
Dim i%, intflag1% 'variables
Select Case Val(txtnum(i).Text)
Case 1 To 49 ' if it is 1 to 49 then do this ...
intflag1 = 0 'set the int flag to 0/Null
frmLottow1.Hide
frmLottow2.Show
Case Else 'otherwie do this ...
intflag1 = 1 'set the intflag to 1/RED ALERT ERROR SYSTEM FALIURE ;)
End Select
Next i 'next textbox
If intflag1 = 0 Then ' if the int flag is 0 then do this ...
frmLottow1.Hide
frmLottow2.Show
Else 'otherwise do this ...
frmLottow1.Show
MsgBox "Only enter numbers 1 - 49"
Exit Sub 'exit the sub routine
End If
|
i hope that helps a bit _________________
:O  |
|
| Back to top |
|
timmy Newbie
Joined: 08 Dec 2003 Posts: 5
|
Posted: Dec 12th, 2003 04:11 PM Post subject: |
|
|
| I got the program figured out. Thanks Dragona, that somewhat helped. |
|
| Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|