Saturday, March 24, 2012

Simple Coding Issue??

Hi All,

Please can u help....

I have a field that requies a zero in it if it is left empty before I can use a hyperlink and this code does not seem to work...

Please can anyone tell me where I am going wrong.........

cheers

Tony

sub blah()

dim getmeout as integer
getmeout = "0"

If txtQuantity.text= " " then txtQuantity.text= getmeout

End sub()You have txtQuantity.text="_" (with a space ... which is different from nothing at all).

You might try:

Dim DefaultValue As Integer = 0

' Get the current entry in the text box
Dim CurrentEntry As String = txtQuantity.Text

' Remove any spaces ... so that " " will reduce to "" (nothing)
CurrentEntry = CurrentEntry.Replace( " ","" ) ' the first has the space, the second doesn't

' Test whether the current entry is empty
If CurrentEntry = String.Empty Then
txtQuantity.Text = DefaultValue
End If

If this doesn't help, can you show in more detail what you're trying to achieve?

0 comments:

Post a Comment