Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I'm trying to implement a simple conversion utility into my VB program. I want the utility to check my text box to see if it is empty, if it is to leave it empty, if not to run the conversion.

 

This is the Code I have been working with that doesn't quite work.

 

Dim dConv As Single

       If dTxtBx Is "" Then
           dConv = 0
       Else
           dConv = dTxtBx.Text
           dConv = dConv / 3.28083
           dTxtBx.Text = dConv
       End If

 

I think my problem is related to the is "" statement. I'm not getting a specific error, but it appears that if the text box is blank the loop is jumping to the else statement and failing at the dconv=dtxtbx.text statement. (this is the first time I tried to put code into a post, hope I did it right.)

Posted

"Is" is the operator for comparing objects. In your case you want to compare values. The dTXTBx.Text property I presume (not the whole object, as your code does) with a string "".

 

Try

 

If dTxtBx.Text = "" Then ....

.nerd

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...