Showing posts with label Textbox. Show all posts
Showing posts with label Textbox. Show all posts

Thursday, August 21, 2008

Numeric only in Textbox

I have function code here. To restrict the input in textbox only for numeric.

Public Function OnlyNumericKeys(KeyAscii As Integer, TextBox As control) As Integer

Select Case KeyAscii
Case 8, 48 To 57, 46 And InStr(TextBox, ".") = 0
Case 45 And InStr(TextBox, "-") = 0

If TextBox.SelStart > 0 Then
KeyAscii = 0
End If
Case Else

KeyAscii = 0

End Select
OnlyNumericKeys = KeyAscii

End Function


Thanks for the help of my friend (mike).

Wednesday, May 14, 2008

How to Clear all Text in a TextBox

First create a variable:
Dim Sayre As Control

Then Type this code in a Button:
For Each sayre In Me
If TypeOf sayre Is TextBox Then
sayre.Text = ""
End If
Next
####################################
Private Sub Command1_Click()
Dim sayre As Control

For Each sayre In Me
If TypeOf sayre Is TextBox Then
sayre.Text = ""
End If
Next
End Sub
####################################