Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Extract chars from a string

Posted on 2004-09-22
3
Medium Priority
?
287 Views
Last Modified: 2010-05-02
Hi there,
I would like take out all the chars of a certain type from a string.

Eg.
Before process
suppliername23/05/04

take out all "/"

Result:
suppliername230504

I thought there was a string fuction to do this but can't seem to find it.

Any suggestions,
Williery10
0
Comment
Question by:williery10
3 Comments
 
LVL 3

Expert Comment

by:AbhishekSharma
ID: 12120525
Use spit function to retrive the values
Example:- "suppliername23/05/04"

a=split("suppliername23/05/04","/")

a is an array of type string

a(0) will return  suppliername23
a(0) will return  05
a(0) will return  04

The Split function returns a zero-based, one-dimensional array that contains a specified number of substrings.

Syntax
Split(expression[,delimiter[,count[,compare]]])
 
0
 
LVL 3

Expert Comment

by:thunder_moose
ID: 12120539
Hi there,

Not too hard... just pass your string to this function:

Function RemoveSlashes(StringToCheck As String) As String
   Dim TempStr As String
   Dim CurChr As Integer

   CurChr = 1
   Do Until CurChr - 1 = Len(StringToCheck)
        Select Case Mid(StringToCheck, CurChr, 1)
               Case "/"
                    TempStr = TempStr
               Case Else
                    TempStr = TempStr & Mid(StringToCheck, CurChr, 1)
        End Select
   CurChr = CurChr + 1
   Loop
   RemoveSlashes = TempStr
End Function

Hope that helps :)
tm
0
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 200 total points
ID: 12120664
Or even simpler:

   sValue = "suppliername23/05/04"
   sValue = Replace(sValue, "/", "")


Hope this helps.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question