1. #1

    VB- How to get the last character in a string?

    I am trying to get the last character from a string into a variable. For example:

    "Dean1"

    I want to get the number 1 out from that string and into a variable...

    So far Ive came up with:

    'begin search for students
    Dim i As Integer
    Dim yellowlength As String
    Dim yellowclass As String
    For i = 0 To 17
    Dim s As String


    s = MenuForm.yellowhouse(i)

    yellowclass = LastIndexOf(s)


    ----

    Another part of the problem is that I cant get the value "s" from a variable in another form. I would of thought that:

    s = MenuForm.yellowhouse(i)

    would of done the trick.. but it just isn't working. :(

    It says "Method or data member not found"

    :(

    Anyone have any ideas on how to get this working at all?

  2. #2
    Junior Firefly
    Joined
    Mar 2003
    Posts
    660

    Re: VB- How to get the last character in a string?

    Right(1,string_name)

    Should extract the first char starting at the right of the string.

    http://msdn2.microsoft.com/en-us/library/dxs6hz0a.aspx

  3. #3
    Senior Firefly
    Joined
    Aug 2004
    Posts
    1,550

    Re: VB- How to get the last character in a string?

    VB.Net?


    To get the last character

    last_char = string1.substring(string1.length - 1)

    to access a variable from another form:

    Declare the variable as public

    and access it using Form.VariableName

  4. #4

    Re: VB- How to get the last character in a string?

    Quote Originally posted by Zizani View Post
    Right(1,string_name)

    Should extract the first char starting at the right of the string.

    http://msdn2.microsoft.com/en-us/library/dxs6hz0a.aspx
    This was excellent! Thanks! [thumbup]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts