Message from discussion
Shorten Code for repeated function use
From: "David McRitchie" <dmcritc...@msn.com>
References: <5a3801c523d6$96b31760$a401280a@phx.gbl> <#gpCLq9IFHA.2072@TK2MSFTNGP10.phx.gbl> <e91W2v#IFHA.2356@TK2MSFTNGP12.phx.gbl>
Subject: Re: Shorten Code for repeated function use
Date: Tue, 8 Mar 2005 10:14:05 -0500
Lines: 23
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1478
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1478
Message-ID: <eLgEfH$IFHA.2704@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.excel.programming
NNTP-Posting-Host: 1Cust174.tnt50.ewr3.da.uu.net 65.229.232.174
Path: g2news1.google.com!news1.google.com!proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed00.sul.t-online.de!t-online.de!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
sorry code correction is:
Function translate(oldString As String, toString As String, _
fromString As String) As String
'David McRitchie, 2005-03-08 programing
' http://groups.google.com/groups?threadm=5a3801c523d6%2496b31760%24a401280a%40phx.gbl
'limited to equal length from and to strings for now
'ref. http://mitvma.mit.edu/cmshelp.cgi?REXX%20TRANSLAT%20(ALL
Dim i As Long, pos As Long, str As String
str = ""
For i = 1 To Len(oldString)
'InStr([start, ]haystack, needle[, compare])
pos = InStr(1, fromString, Mid(oldString, i, 1), vbBinaryCompare)
If pos = 0 Then
str = str & Mid(oldString, i, 1)
Else
str = str & Mid(toString, pos, 1) '-- corrected
End If
Next i
translate = str
End Function