How do I get the position of a char in a string? Thank you.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a descripion of a card that includes name and
denomination preceded by a $ sign like this:

Better card $5
Better card $10
Better card $02

and I need to be able to get the numbers after de $ sign,
any Ideas please.


Thank you very much.
 
Hi,

Dim str As String = "Better card $5"

Dim intPos As Integer

intPos = str.IndexOf("$")

MessageBox.Show(intPos.ToString, str)

Ken
 
I have a descripion of a card that includes name and
denomination preceded by a $ sign like this:

Better card $5
Better card $10
Better card $02

and I need to be able to get the numbers after de $ sign,
any Ideas please.

Have a look at the methods
- indexof
- substring
of the string class.
 
* said:
I have a descripion of a card that includes name and
denomination preceded by a $ sign like this:

Better card $5
Better card $10
Better card $02

and I need to be able to get the numbers after de $ sign,
any Ideas please.

You can use the 'IndexOf' method or
'Microsoft.VisualBasic.Strings.InStr' to look for the character. Use
the string's 'Substring' method or 'Microsoft.VisualBasic.Strings.Mid'
to extract a piece of the string.
 
Hi,

This simple ones we have to anwer all as I always see

Dim a As String = "better card $02"
MessageBox.Show(a.Substring(a.IndexOf("$") + 1))

I hope this helps a little bit?

Cor
 
Back
Top