Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » General

Post new topic   Reply to topic
input box and list trouble
View previous topic :: View next topic  
Author Message
timmy
Newbie


Joined: 08 Dec 2003
Posts: 5

PostPosted: Dec 11th, 2003 05:55 PM    Post subject: input box and list trouble Reply with quote

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
View user's profile Send private message Send e-mail AIM Address
Dragona
Newbie


Joined: 11 Dec 2003
Posts: 7

PostPosted: Dec 12th, 2003 04:23 AM    Post subject: Reply with quote

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
_________________
Biggrin :O Biggrin
Back to top
View user's profile Send private message
timmy
Newbie


Joined: 08 Dec 2003
Posts: 5

PostPosted: Dec 12th, 2003 04:11 PM    Post subject: Reply with quote

I got the program figured out. Thanks Dragona, that somewhat helped.
Back to top
View user's profile Send private message Send e-mail AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » General All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic