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
A To Z
View previous topic :: View next topic  
Author Message
Dragona
Newbie


Joined: 11 Dec 2003
Posts: 7

PostPosted: Dec 16th, 2003 06:21 AM    Post subject: A To Z Reply with quote

hi im doing a select case statement so that it will only alow numbers 1 to 49 in but for some reason it wont block here is the code

Code:


    Select Case Val(txtnum(i).Text)
        Case 1 To 49
            intflag1 = 0
            frmLottow1.Hide
            frmLottow2.Show
        MsgBox "Please only enter numbrs from 1 to 49"
        Case Else
            intflag1 = 1
    End Select
    Next i
If intflag1 = 0 Then
    frmLottow1.Hide
    frmLottow2.Show
ElseIf intflag1 = 1 Then
    frmLottow1.Show
    MsgBox "Only enter numbers 1 - 49"
    Exit Sub
End If



i know i need to tidy up my code and shortent it buy not using those if statements

but ne wayz i think that should be blocking apha characters getting through but it doesnt. i worked out a way but thats on a computer miles away Sad

ive also tried this but it wants a and z to be a variable

Code:

    Select Case Val(txtnum(i).Text)
        Case 1 To 49
            intflag1 = 0
            frmLottow1.Hide
            frmLottow2.Show
        Case A To z
        intflag1 = 1
        MsgBox "Please only enter numbrs from 1 to 49"
        Case Else
            intflag1 = 1
    End Select
    Next i
If intflag1 = 0 Then
    frmLottow1.Hide
    frmLottow2.Show
ElseIf intflag1 = 1 Then
    frmLottow1.Show
    MsgBox "Only enter numbers 1 - 49"
    Exit Sub
End If

_________________
Biggrin :O Biggrin
Back to top
View user's profile Send private message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Dec 16th, 2003 12:35 PM    Post subject: Reply with quote

Hi!

Check this code below:

Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
'Check if its number only
If KeyAscii >= 48 And KeyAscii <= 57 Then
    'Check the length of textbox should not be greater than 2 chars.
    If Len(Text1.Text) >= 2 Then KeyAscii = 0: Exit Sub
End If
End Sub


Thanks!
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
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