Solved

Extract chars from a string

Posted on 2004-09-22
3
279 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 50 total points
ID: 12120664
Or even simpler:

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


Hope this helps.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now