|
-
Nov 4th, 2000, 09:47 PM
#1
Thread Starter
PowerPoster
Here's my dillema, i have a text box which must hold 8 numbers, no letters, and when enter is pressed, it calls a command_click event. I can't use the max length property because some of the numbers that i'm pulling from a database are over 8 characters, and i need to go in and edit them all. I can't figure out how to implement this?? Thanks
-
Nov 4th, 2000, 10:13 PM
#2
Addicted Member
What are you trying to use the MaxLength property for? Are you needing help calling the Command_click event? Do you want to check to see if all of the characters in the textbox are numbers? I guess that I just need you to explain what exactly you need help with.
-
Nov 4th, 2000, 10:41 PM
#3
on keypress event
if not isnumeric(chr(keyascii)) _
and keysacii <> vbkeyreturn and len(text1)> 7 then
keyascii = 0
end if
if keyascii = vbkeyreturn then
call command_click
end if
this will allow your textbox to accept upto 8 numbers only.
-
Nov 4th, 2000, 11:01 PM
#4
Thread Starter
PowerPoster
I tried that last response, it allows letters to be entered, and also more than 8 numbers can be entered. Anyone else with some ideas.
-
Nov 4th, 2000, 11:24 PM
#5
transcendental analytic
Code:
Private Sub Form_Load()
Text1.Tag = "00000000"
Text1.Text = "00000000"
End Sub
'or maybe you just change those properties in designtime
Private Sub Text1_Change()
Dim x&
x = Text1.SelStart
If Left(Text1, 8) Like "########" Then
Text1 = Left(Text1, 8)
Text1.Tag = Text1
Else
Text1 = Text1.Tag
End If
Text1.SelStart = x
End Sub
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Nov 6th, 2000, 04:06 AM
#6
sorry about that. i was not able to test the code.
here's the tested code.
Private Sub Text1_KeyPress(KeyAscii As Integer)
If (Len(Text1) > 7 Or Not IsNumeric(Chr(KeyAscii))) And _
KeyAscii <> vbKeyReturn And _
KeyAscii <> vbKeyBack Then
KeyAscii = 0
End If
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|