VBA Strings

Discussion in 'Software' started by BMD, Jan 19, 2006.

  1. BMD

    BMD Private E-2

    Hi all,
    I'm using VBA with Compuware's Test Partner automated testing tool. I have a string X982064 or 87563983 I need to say if X is first then this, remove the X and type the numbers. If there is no X then do this other thing. I don't know how to do a left function is VB or how to remove the X and enter the number.

    Any pointers?
    Thanks,
    BMD
     
  2. Kodo

    Kodo SNATCHSQUATCH

    Code:
    if left(strVar,1)="X" then
    'do something
    strVar=right(strVar,len(strVar)-1) ' will give you  the value without the x
    else
    'do something else
    end if
    
    you could also do
    strVar=replace(strVar,"x","") instead of the RIGHT() function, but I don't kow if X will appear in the string again or not. If not, then use replace as demonstrated.
     
  3. BMD

    BMD Private E-2

    Thanks I might have a rebuttal about length
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds