Solved

Extract chars from a string

Posted on 2004-09-22
3
282 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

809 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