Question about string manipulation - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Question about string manipulation

I am writing an Excel Macro and need a little help.

I populate a field with the value of a cell from my spreadsheet.

Serial_Number = Worksheets(1).Cells((i + Caselp), 8).Value

My customer wants me to remove the first 2 characters from the Serial Number.

How do I remove the first 2 characters from my varialbe Serial_Number?

Can you reference each character of a string? In C I can reference the 3rd element of a string by using variable_name[2]. Is there anything similar?


Comments

  • infidelinfidel Posts: 2,900Member
    : I am writing an Excel Macro and need a little help.
    :
    : I populate a field with the value of a cell from my spreadsheet.
    :
    : Serial_Number = Worksheets(1).Cells((i + Caselp), 8).Value
    :
    : My customer wants me to remove the first 2 characters from the Serial Number.
    :
    : How do I remove the first 2 characters from my varialbe Serial_Number?
    :
    : Can you reference each character of a string? In C I can reference the 3rd element of a string by using variable_name[2]. Is there anything similar?

    In VB, strings are not considered arrays. Technically they are arrays where each character is two bytes long, but you can't simply refer to mystring[3]. What you CAN do, which is much easier anyways, is use the Mid() function:

    Const constr = "Hello, world!"
    MsgBox Mid(constr, 2)


Sign In or Register to comment.