Replace String

Replace String

Anonymous
Not applicable
280 Views
3 Replies
Message 1 of 4

Replace String

Anonymous
Not applicable
I need to replace the backslashes "\" to a forward slash "/" in a text
string and pass it on to a LISP routine. Is there a function that would do
the replacement for me in VB?

Thanks
Mayu
0 Likes
281 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
Here is an example of how to do what you want.

Public Sub Start()
Dim strString As String
Dim strReversed As String
Dim intPosition As Integer

strString = "C:\Program Files\MyDrawing.dwg"

For intPosition = 1 To Len(strString)
If Mid(strString, intPosition, 1) = "\" Then
strReversed = strReversed & "/"

Else
strReversed = strReversed & Mid(strString, intPosition, 1)
End If
Next intPosition
End Sub
--
Joe Sutphin
Author of "AutoCAD 2000 VBA Programmers Reference"
ISBN #1861002564

Checkout Sources - The magazine dedicated to AutoCAD customization
http://vbdesign.hypermart.net/sources/sources.htm

"Mayu Roy" wrote in message
news:[email protected]...
> I need to replace the backslashes "\" to a forward slash "/" in a text
> string and pass it on to a LISP routine. Is there a function that would do
> the replacement for me in VB?
>
> Thanks
> Mayu
>
0 Likes
Message 3 of 4

Anonymous
Not applicable
Public Function BackSlashToForeSlash(InputStr As String) As String
Dim ch As String
Dim StrOut As String
Dim i As Integer
For i = 1 To Len(InputStr)
ch = Mid(InputStr, i, 1)
if ch = "\" then
strOut = strOut & "/"
else
strOut = strOut & ch
End If
Next i
BackSlashToForeSlash = strOut
End Function

Mayu Roy wrote:
>
> I need to replace the backslashes "\" to a forward slash "/" in a text
> string and pass it on to a LISP routine. Is there a function that would do
> the replacement for me in VB?
>
> Thanks
> Mayu

--

Checkout the AcadX(tm) ActiveX Extension Library at:

http://www.caddzone.com/acadx/acadx.htm

/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* [email protected] */
/* http://www.caddzone.com */
/*********************************************************/
0 Likes
Message 4 of 4

Anonymous
Not applicable
There is also a built-in function in VB called Replace

Let txtACSize = Replace(txtACSize.Text, "X", "x")

This will replace the big X with a little x if it exists in the text string

There is more info in the MSDN Library.

Anna Wood

"Tony Tanzillo" wrote in message
news:[email protected]...
>
> Public Function BackSlashToForeSlash(InputStr As String) As String
> Dim ch As String
> Dim StrOut As String
> Dim i As Integer
> For i = 1 To Len(InputStr)
> ch = Mid(InputStr, i, 1)
> if ch = "\" then
> strOut = strOut & "/"
> else
> strOut = strOut & ch
> End If
> Next i
> BackSlashToForeSlash = strOut
> End Function
>
> Mayu Roy wrote:
> >
> > I need to replace the backslashes "\" to a forward slash "/" in a text
> > string and pass it on to a LISP routine. Is there a function that would
do
> > the replacement for me in VB?
> >
> > Thanks
> > Mayu
>
> --
>
> Checkout the AcadX(tm) ActiveX Extension Library at:
>
> http://www.caddzone.com/acadx/acadx.htm
>
> /*********************************************************/
> /* Tony Tanzillo Design Automation Consulting */
> /* Programming & Customization for AutoCAD & Compatibles */
> /* ----------------------------------------------------- */
> /* [email protected] */
> /* http://www.caddzone.com */
> /*********************************************************/
0 Likes