special characters in a string

prav_roy

Well-known member
Joined
Sep 10, 2005
Messages
70
Location
Mumbai
Programming Experience
1-3
i want to check special character in a string
for example i have a string like
"Praveen Desa" praveen@yahoo.com
above is my string, i want to check for " and i need to exstract the name between two ""
how to do tht please help me
 
btw, if really want to get your hands dirty with string manipulation you could have a look at the REGEX class. It stands for regular expressions and is my prefered way to work with strings, the syntax looks totally alien but once you get the hang of it it is much more efficient.
 
I want a function passing $ in textbox preceding integer

I know this should be simple but I getting hung up trying to make this work. My want the dollar sign $ to preceed any integers in front of one text box.

Private Function adddollarsign(ByVal Number As Integer) As Integer
Return Number + "$"
End Function

Private Sub cas_dollars_dispatched_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cas_dollars_dispatched.TextChanged
Dim cas_dollars_dispatched As Integer = ""
cas_dollars_dispatched = adddollarsign(cas_dollars_dispatched)
End Sub

Thanks for the help
 
Integers can only hold numbers, so adding a "$" which is not a number, isn't allowed

however you can hold the value as a string instead, string can hold any ascii character (numbers, letters, symbols)
VB.NET:
Private Function AddDollarSign(ByVal Number As Integer) As String
  Return "$" & Number.ToString
End Function

Private Sub cas_dollars_dispatched_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cas_dollars_dispatched.TextChanged
  Dim cas_dollars_dispatched As String = ""
  cas_dollars_dispatched = AddDollarSign(cas_dollars_dispatched)
End Sub

or even easier, just use the FormatCurrency function that's already in the framework:
FormatCurrency(YourNumberHere)

VB.NET:
 Private Sub cas_dollars_dispatched_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cas_dollars_dispatched.TextChanged
  Dim cas_dollars_dispatched As String = ""
  cas_dollars_dispatched = FormatCurrency(cas_dollars_dispatched)
 End Sub
 
To format as currency: cas_dollars_dispatched.ToString("c")
To format as a percentage: cas_dollars_dispatched.ToString("p")
etc.

Standard Numeric Format Strings

Note that FormatCurrency and ToString("c") will use the local currency format, whatever that is. This may or may not be what you desire outside of the US.

Also, elpeak, this wasn't specifically related to the original question so it should have been asked in a new thread.
 
Back
Top