
You'd think this works, but it doesn't
From the help:
String.Remove Method
Deletes a specified number of characters from this instance beginning at a
specified position.
ByVal startIndex As Integer, ByVal count As Integer
Parameters
startIndex
The position in this instance to begin deleting characters.
count
The number of characters to delete.
"$" is not an integer value, which the first paramter of remove "startIndex"
must be, so the compiler gives you an error. In addition, an empty string
"" is not a valid integer value, which the second paramter "count" must be.
Quote:
> I've been seeing this a lot in my code. I try to convert strings to
> some type of integer and it gives me trouble... Why should this code
> not work? Someone please tell me! The compiler breaks on the first
> line, the "If" line... now since the Remove function returns the
> string, and it is removing the $ from it (the only non-integer
> character), you'd think it'd nicely convert... But it doesnt.
> If System.Convert.ToDecimal(t_Cost.Text.Remove("$", "")) > 0
> Then
> Me.t_markup.Text =
> System.Math.Round(System.Convert.ToDecimal(t_Price.Text.Remove("$",
> "")), 2)
> End If
> ?
> SX