Trim Variable

L

Les Stout

Hi all, i have a string variable and i need to replace the first 12
places (Left side), which are 8 numeric (Variable) and 4 spaces,
(constant). Is it possible to do this and if so could you please help
with some code.

thanks in advance.

Les Stout
 
G

Guest

This is how I understand what you are asking, hope I have it right: You want
code that will "overwrite" the first 12 characters of your string, so these
characters will be erased and replaced with an 8 digit number that you have
in a different string variable and then 4 spaces. If that is it, then this
should do:
MyString = DigitString & " " & Right(MyString, Len(MyString)-12)
 
T

Tom Ogilvy

sStr = "12345678 The Big Dog"
sStr = Right(sStr,len(sStr)-12)

demo'd from the immediate window:

sStr = "12345678 The Big Dog"
sStr = Right(sStr,len(sStr)-12)
? sStr
The Big Dog
 
M

Mike Fogleman

Sub Replace()
Dim sVar As String
Dim WhatEver As String

sVar = Right(sVar, Len(sVar) - 12)
WhatEver = "whatevruwant"
sVar = WhatEver & sVar
End Sub

Mike F
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top