leftmost letter extract in vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • charvi
    New Member
    • May 2007
    • 121

    leftmost letter extract in vb.net

    hi
    how to get the first letter of name for eg n in Nilesh in vb.net
  • yudhbir
    New Member
    • Apr 2008
    • 1

    #2
    Originally posted by charvi
    hi
    how to get the first letter of name for eg n in Nilesh in vb.net

    You should have a string variable, do simply like below

    Dim s As String
    s = "test"
    s = s.Substring(0, 1)



    and you will get the first letter of any string.

    if you need in a char, do this
    Dim c As Char
    c = Convert.ToChar( s)

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      You can also treat a string just like char array and address it by index to get a single char.
      [code=vbnet]
      Dim s as string
      Dim c as char
      s="Test"
      c=s(0)
      [/code]

      Comment

      Working...