Click here to Skip to main content
15,895,606 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: TAB control change tab order Pin
Tom John14-Dec-04 22:58
Tom John14-Dec-04 22:58 
GeneralNeed rectangle box with little compartments. Pin
preesteya12-Dec-04 14:12
preesteya12-Dec-04 14:12 
GeneralRe: Need rectangle box with little compartments. Pin
Tom John13-Dec-04 0:27
Tom John13-Dec-04 0:27 
QuestionHow to call a MouseEvent from a Keyboard Event Handler? Pin
manivannan.p12-Dec-04 6:29
manivannan.p12-Dec-04 6:29 
AnswerRe: How to call a MouseEvent from a Keyboard Event Handler? Pin
Dave Kreskowiak13-Dec-04 2:05
mveDave Kreskowiak13-Dec-04 2:05 
GeneralBeginner: converting stings and integers Pin
toefuti11-Dec-04 23:45
toefuti11-Dec-04 23:45 
GeneralRe: Beginner: converting stings and integers Pin
Edbert P12-Dec-04 13:37
Edbert P12-Dec-04 13:37 
GeneralRe: Beginner: converting stings and integers Pin
John Santora18-Dec-04 17:10
sussJohn Santora18-Dec-04 17:10 
The VB6 Numeric function has a shortcoming that I can't recall just now. I think it may parse a string like "12 34 56" that contains spaces automatically, and return 12 to you. Something like that.

Anyway, over the years I've found that you can't give a user too much information when it comes to error messages. Sometimes its just late and they can't tell a 0 from a o, or a 1 from a l. You're code knows exactly what the problem is, so you might as well be precise in your error message. Here's the routine I use.

Public Function Numeric(ByVal sNum As String, ByRef sErrMsg As String, _
Optional sOtherLegalChars As Variant, _
Optional vIncludeValidCharMsg As Variant) As Boolean

Const sValidDigits = "0123456789"

Dim sValidChars As String

Dim i As Integer
If IsMissing(sOtherLegalChars) Then sOtherLegalChars = ""
sValidChars = sValidDigits & sOtherLegalChars

If IsMissing(vIncludeValidCharMsg) Then vIncludeValidCharMsg = True

' Return error message only if a problem is found.
' Caller will get a true AND an empty errMsg string.
' or
' will get False AND an error message in the errMsg String.

sErrMsg = ""

If Len(sNum) = 0 Then
Numeric = False
sErrMsg = "Numeric value is missing or empty. Numeric digits were not found. [E0203262000]"
Exit Function
End If

For i = 1 To Len(sNum)
If InStr(sValidChars, Mid(sNum, i, 1)) = 0 Then
Numeric = False
sErrMsg = "The value " & quote(sNum) & " contains the non-numeric character " & _
quote(Mid(sNum, i, 1)) & " in position " & CStr(i) & ". [E0203262001]" & _
IIf(vIncludeValidCharMsg, vbCrLf & "The following are the only valid characters you can use: " & quote(sValidChars), "")
Exit Function
End If
Next i

On Error Resume Next
Dim L As Long
L = CLng(sNum)
Const vbOverflowErr = 6
If Err.number = 0 Then
Numeric = True
ElseIf Err.number = vbOverflowErr Then
sErrMsg = "Value " & quote(sNum) & " is too big. the biggest number allowed is about 2 billion. [E0301152200]"
Numeric = False
Else
sErrMsg = "Value " & quote(sNum) & " is not numeric [E03011522010]. The Microsoft error message is " & quote(Err.Description)
Numeric = False
End If
On Error GoTo 0

End Function
GeneralRe: User Controls? Pin
Mekong River11-Dec-04 16:47
Mekong River11-Dec-04 16:47 
GeneralRe: User Controls? Pin
hermitbluedog12-Dec-04 2:14
hermitbluedog12-Dec-04 2:14 
Questionmore efficient mp3 control? Pin
Nadroj11-Dec-04 7:42
Nadroj11-Dec-04 7:42 
Generalvb dll Pin
Member 158209411-Dec-04 7:30
Member 158209411-Dec-04 7:30 
GeneralRe: vb dll Pin
Dave Kreskowiak11-Dec-04 9:43
mveDave Kreskowiak11-Dec-04 9:43 
GeneralRe: vb dll Pin
A.Kishior12-Dec-04 9:06
A.Kishior12-Dec-04 9:06 
GeneralVB .NET 03' Textbox using return key for entry Pin
SpinningCone11-Dec-04 6:32
sussSpinningCone11-Dec-04 6:32 
GeneralRe: VB .NET 03' Textbox using return key for entry Pin
MohammadAmiry11-Dec-04 22:47
MohammadAmiry11-Dec-04 22:47 
Generalvb6.0 email code asked for !!!!!!! Pin
Mohammad Daba'an10-Dec-04 22:53
Mohammad Daba'an10-Dec-04 22:53 
GeneralRe: vb6.0 email code asked for !!!!!!! Pin
Mekong River11-Dec-04 4:09
Mekong River11-Dec-04 4:09 
GeneralRe: vb6.0 email code asked for !!!!!!! Pin
Mohammad Daba'an12-Dec-04 21:05
Mohammad Daba'an12-Dec-04 21:05 
Questionhow to send a directory in lan messenger Pin
parada10-Dec-04 19:49
parada10-Dec-04 19:49 
AnswerRe: how to send a directory in lan messenger Pin
Dave Kreskowiak11-Dec-04 4:15
mveDave Kreskowiak11-Dec-04 4:15 
GeneralResource file cursor problem... Pin
TAlvord10-Dec-04 10:20
TAlvord10-Dec-04 10:20 
GeneralRe: Resource file cursor problem... Pin
Mekong River11-Dec-04 4:15
Mekong River11-Dec-04 4:15 
GeneralText box validation for Last name Pin
sangsram10-Dec-04 6:45
sangsram10-Dec-04 6:45 
GeneralRe: Text box validation for Last name Pin
nitin_ion10-Dec-04 20:19
nitin_ion10-Dec-04 20:19 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.