Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb6 ltrim - rtim question

Status
Not open for further replies.

theyikews

Programmer
Mar 22, 2024
1
GB
hey all! Before i begin i want to make it clear I'm not some lazy student looking for easy answers. I'm just a regular guy looking for a bit of help. So having said that let me begin:

I have a text string that i need to trim a certain amount of text at the left hand side.

here's an example of the text:

thisisatest:thisismorerandomtext:text

I need to trim everything on the left up to the first Colon.

this text changes so i can't specify numerically the length i need to be able to automatically select all text up to the first : (colon)

Has anyone got any tips that might help me?
 
[tt]Instr[/tt] is your friend for this. (But this is a VB.NET forum, not VB6)
 
I hope this code still works in VB6:

Code:
Dim lsSrcStr As String = "thisisatest:thisismorerandomtext:text"
Dim lsRetStr As String = Mid(lsSrcStr, InStr(1, lsSrcStr, ":") + 1)

HTH.

Regards,

Ilya
 
Nope, that won't work in VB6. You'd have to separate the type declaration from the assignment.
 
StrongM said:
You'd have to separate the type declaration from the assignment.

Rite!
Forgot about it. Too much of .NET VB (+ some C#)...

"Forgive me Father coz I have sinned!" [bowleft]

To my defense, last time I worked in VB6 was in 2002...

(Am I absolved? [smile])

Regards,

Ilya
 
VB6 - Another way - the Split() function could be your friend:

Code:
Option Explicit

Sub theyikews()
Dim ary() As String
Dim str As String
Dim X As Integer

str = "thisisatest:thisismorerandomtext:text"
ary = Split(str, ":")

For X = LBound(ary) + 1 To UBound(ary)
    Debug.Print ary(X)
Next X

End Sub

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top