|
-
Dec 28th, 2010, 07:16 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Remove 3 leftmost characters
Hi everyone,
I need help regarding following situation:
I have some data in a table which stores supplier name, every supplier name starts with M/S like this:
M/S ALPHA
M/S BRAVO
M/S CHARLIE
I want to remove "M/S" from the whole field.
Can anybody help me in this regard.
Thanks in advance.
-
Dec 28th, 2010, 07:26 AM
#2
Re: Remove 3 leftmost characters
Use the VB REPLACE function and replace M/S with ""
Example:
Code:
Text1.Text = "M/S ALPHA"
Text1.Text = Replace(Text1.Text, "M/S","")
-
Dec 28th, 2010, 07:28 AM
#3
Re: Remove 3 leftmost characters
In case the left three characters can change, or if they appear elsewhere in the string you can do
Code:
Text1.Text = "M/S ALPHA M/S..."
Text1.Text = Right$(Text1.Text, Len(Text1.Text) - 3)
-
Dec 28th, 2010, 08:09 AM
#4
Re: Remove 3 leftmost characters
And because there is more than one way to skin a cat.....
Code:
Private Sub Command1_Click()
Text1.Text = "M/S ALPHA"
'Remove M/S from the string
Text1.Text = Mid(Text1.Text, 4)
'Trim the leading space that is left
Text1.Text = Trim(Text1.Text)
End Sub
-
Dec 28th, 2010, 11:46 AM
#5
Thread Starter
Hyperactive Member
Re: Remove 3 leftmost characters
Thanks to all for reply, all mentioned code is working but i want to remove 3 leftmost characters from "Supplier" column of "tbSupplier" table which is of MS Access table having field (column) of "Supplier". I want to remove its 3 character once from whole column through VB 6.0 code. Hope u will understand my problem and reply.
-
Dec 28th, 2010, 11:55 AM
#6
Re: Remove 3 leftmost characters
Access does support the REPLACE function in SQL queries so you can run an UPDATE query against that table useing REPLACE (as indicated in my first post) and that should clear up your supplier table.
-
Dec 30th, 2010, 01:57 AM
#7
Thread Starter
Hyperactive Member
Re: Remove 3 leftmost characters
Thanks for reply, your suggestion was very good for me to improve my knowledge, in this scenario, i want to remove characters once a time from the whole column, i want to create a button for this work, when i press button only one time then all data of column "Supplier" will be replaced, can i put your code in a loop? if yes then what will be the procedure. Kindly guide me.
-
Jan 5th, 2011, 10:58 PM
#8
Thread Starter
Hyperactive Member
Re: Remove 3 leftmost characters
Hi,
Plz reply my earlier post # 7, i want to remove all data in once, if i press one time command button then all data in column "Supplier" will remove or replace, can you guide me in this regard. As i still in trouble
-
Jan 5th, 2011, 11:09 PM
#9
Re: Remove 3 leftmost characters
Use an Update/Edit query. MS Access allows use of Left, Mid & Right functions within the query string. Try writing your query in Access' Query Designer and when you get it working, copy & paste into your VB project remembering to string-format it as needed.
-
Jan 13th, 2011, 12:20 PM
#10
Thread Starter
Hyperactive Member
Re: Remove 3 leftmost characters
Thanks to all, it is solved my problem, I am very thankful to all of you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|