Click here to Skip to main content
16,008,299 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: word document Pin
Christian Graus5-Jul-07 1:16
protectorChristian Graus5-Jul-07 1:16 
GeneralRe: word document Pin
Christian Graus5-Jul-07 1:43
protectorChristian Graus5-Jul-07 1:43 
AnswerRe: word document Pin
Sathesh Sakthivel5-Jul-07 1:30
Sathesh Sakthivel5-Jul-07 1:30 
GeneralRe: word document Pin
Christian Graus5-Jul-07 2:22
protectorChristian Graus5-Jul-07 2:22 
AnswerRe: dim f as string Pin
CPallini5-Jul-07 0:48
mveCPallini5-Jul-07 0:48 
GeneralRe: dim f as string Pin
magedhv5-Jul-07 1:05
magedhv5-Jul-07 1:05 
GeneralRe: dim f as string Pin
Christian Graus5-Jul-07 1:13
protectorChristian Graus5-Jul-07 1:13 
QuestionNumerical textbox validation, how to handle an empty string? [modified] Pin
MatthysDT5-Jul-07 0:09
MatthysDT5-Jul-07 0:09 
I want to validate that my textbox contains a numerical value.
I do this in the "textbox.validating" event, everything works fine until all the text is cleared and the box has an empty string. The validation doesn't allow an empty string because it's not numerical (no matter how I code it). But this field is not compulsory for the user to enter, so he should be able to enter either a numerical value or an empty string.

Here is my code so far, it doesn't work for empty strings, textbox remains invalidated and forces focus onto the control.

Private Sub MyMaskedTextBox_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyMaskedTextBox.Validating
    Dim num As Double
    If Me.MyMaskedTextBox.Text = "" Or IsDBNull(Me.MyMaskedTextBox.Text) Then
        MyErrorProvider.SetError(Me.MyMaskedTextBox, "")
    Else
        Try
            num = Me.MyMaskedTextBox.Text
            MyErrorProvider.SetError(Me.MyMaskedTextBox, "")
        Catch ex As Exception
            MyErrorProvider.SetError(Me.MyMaskedTextBox, "Value must be numeric")
        End Try
    End If

End Sub


This is a real problem because nothing I've tried so far allows the user to enter an empty string!
Can't I somehow force the field to validate even if the contents don't match the validation criteria?

_______________________________________________________________________
http://www.readytogiveup.com/[^]
"you can't forget something you never knew..." M. Du Toit

"Watching Migthy Joe Young made me hate my life..................................I want a gorilla!" A. Havemann


AnswerRe: Numerical textbox validation, how to handle an empty string? Pin
SHatchard5-Jul-07 0:19
SHatchard5-Jul-07 0:19 
QuestionRe: Numerical textbox validation, how to handle an empty string? Pin
MatthysDT5-Jul-07 1:25
MatthysDT5-Jul-07 1:25 
NewsRe: Numerical textbox validation, how to handle an empty string? Pin
MatthysDT5-Jul-07 1:55
MatthysDT5-Jul-07 1:55 
AnswerRe: Numerical textbox validation, how to handle an empty string? Pin
cutequencher5-Jul-07 6:05
cutequencher5-Jul-07 6:05 
GeneralRe: Numerical textbox validation, how to handle an empty string? Pin
MatthysDT6-Jul-07 0:51
MatthysDT6-Jul-07 0:51 
AnswerAnswer.... Pin
MatthysDT16-Jul-07 2:36
MatthysDT16-Jul-07 2:36 
AnswerRe: word document Pin
Christian Graus4-Jul-07 23:47
protectorChristian Graus4-Jul-07 23:47 
QuestionImage Icon in setup program Pin
ShuklaGirish4-Jul-07 23:06
ShuklaGirish4-Jul-07 23:06 
AnswerRe: Image Icon in setup program Pin
kubben5-Jul-07 2:46
kubben5-Jul-07 2:46 
AnswerRe: Image Icon in setup program Pin
pashitech5-Jul-07 5:47
pashitech5-Jul-07 5:47 
GeneralRe: Image Icon in setup program Pin
ShuklaGirish5-Jul-07 18:52
ShuklaGirish5-Jul-07 18:52 
QuestionHow to pass value of a variable of one form to the next in vb.net Pin
Projrct_Friend's4-Jul-07 21:56
Projrct_Friend's4-Jul-07 21:56 
AnswerRe: How to pass value of a variable of one form to the next in vb.net Pin
Johan Hakkesteegt4-Jul-07 22:14
Johan Hakkesteegt4-Jul-07 22:14 
GeneralRe: How to pass value of a variable of one form to the next in vb.net Pin
Christian Graus5-Jul-07 1:11
protectorChristian Graus5-Jul-07 1:11 
AnswerRe: How to pass value of a variable of one form to the next in vb.net Pin
Mycroft Holmes4-Jul-07 23:01
professionalMycroft Holmes4-Jul-07 23:01 
GeneralRe: How to pass value of a variable of one form to the next in vb.net Pin
Johan Hakkesteegt4-Jul-07 23:21
Johan Hakkesteegt4-Jul-07 23:21 
AnswerRe: How to pass value of a variable of one form to the next in vb.net Pin
Christian Graus5-Jul-07 1:12
protectorChristian Graus5-Jul-07 1:12 

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.