Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: input numeric value in userform text box

$
0
0

Afternoon Massimo,

Give this a try:

Private Sub TextBox_corquo_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If Len(TextBox_corquo.Value) = 0 Then
    Select Case KeyAscii
        Case 45, 48 To 57
        Case Else
            KeyAscii = 0
    End Select
End If
If Len(TextBox_corquo.Value) >= 1 Then
    Select Case KeyAscii
        Case 48 To 58
'Do nothing, numbers are permitted
        Case 46
            If InStr(TextBox_corquo.Value, ".") > 0 Then
                KeyAscii = 0
            Else
'Do nothing, only one decimal point allowed.
            End If
        Case Else
            KeyAscii = 0
    End Select
End If
End Sub

Private Sub TextBox_corquo_AfterUpdate()
ValidateInput
Debug.Print corquo
End Sub

Private Sub ValidateInput()
If TypeName(Me.ActiveControl) = "TextBox" Then
    With Me.ActiveControl
        If .Value <> vbNullString Then
            If Not IsNumeric(.Value) Then
                MsgBox "Solo i valori numerici consentiti"
                .Value = vbNullString
            Else
                corquo = CDbl(TextBox_corquo.Value)
            End If
        Else
            MsgBox "Inserire un numero valido"
        End If
    End With
End If
End Sub

Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>