Solved

Extract chars from a string

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DIR issue 7 53
VBS file using code from 2nd file (txt or vbs) 4 36
VBA/SQL - Connect to SQL server and pull data 4 106
message box in access 4 46
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

815 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

8 Experts available now in Live!

Get 1:1 Help Now