H
Herfried K. Wagner [MVP]
* "Cor Ligthert said:MyString.empty
myString = Nothing
myString = ""
Are all the same
They are not the same, 'Nothing' is a null reference, 'Empty', or '""'
are not.
* "Cor Ligthert said:MyString.empty
myString = Nothing
myString = ""
Are all the same
did I write Is Nothing?They are not the same, 'Nothing' is a null reference, 'Empty', or '""'
are not.
If txtWInch.Text Is Nothing
Did you see that Hefried wrote that when you put on Option Strict on you
would be warned, why you did not do that.
* "Cor Ligthert said:did I write Is Nothing?
Although = Nothing acts the same as Is nothing when there is no reference.
* "Cor Ligthert said:His name is Herfried, would give me a long message when I did not correct
that.
If Me.txtLInch.Text Is Nothing Then LInch = 0 Else
Me.LInch = CType(Me.txtLInch.Text, Integer)
Me.LFeet = Me.txtLFeet.Text
'Me.LInch = Me.txtLInch.Text
Me.WFeet = Me.txtWFeet.Text
'Me.WInch = Me.txtWInch.Text
'Me.TFeet = Me.txtTFeet.Text
Me.TInch = Me.txtTInch.Text
you should check the contents of the text boxes first to see if they can be
converted to numbers. - (use the isnumeric function)
then you should convert to and assign to -> variables of a numeric data
type - like double.
then use the numeric variables to do your calculations.
by the way - at the top - you should type 'option strict on' and 'option
explicit on'
vb 6.0 was much easier to learn for newbies.
Scott,
I hope that this sample makes clear what I want to say.
\\\\
Dim str As String = "12E4"
If IsNumeric(str) Then
MessageBox.Show(CLng(str).ToString)
End If
///
* David said:In which case you just threw an exception if str doesn't fit into a
long. IsNumeric probably took *longer* to run than the CLng, and still
didn't tell you if the CLng would be a valid call.
David said:In which case you just threw an exception if str doesn't fit into a
long. IsNumeric probably took *longer* to run than the CLng, and still
didn't tell you if the CLng would be a valid call.
Which you can make yourself of course by just making a methode which does aThat's why there will be a 'TryParse' method for the 'Int32' datatype in
.NET 2.0.
* "Cor Ligthert said:Which you can make yourself of course by just making a methode which does a
simple calculation. When an error is thrown you know there it is not numeric
or whatever test you put in it, however I do not find that elegant.
Sure, you can implement such a method currently too. Nevertheless, I
prefer a speed-optimized version that comes out of the box.
Agree, I normally use String.Empty, although I use "" also.Better to use string.empty instead.
Not really, the compiler, CLR & JIT will intern "" to the same "" thatusing "" means vb creates a new string for each ""