Article View: be.comp.programming
Article #15036Re: slotspaties uit een string halen (VB)
From: Hugo Maes
Date: Mon, 20 Nov 2000 00:00
Date: Mon, 20 Nov 2000 00:00
63 lines
2824 bytes
2824 bytes
"Vincent (test usenet)" wrote:
> Zoals in de commentaren staat, doet het ding wel wat het moet doen,
> behalve dan dat er opp het einde van kl_uri een hele hoop spaties staan,
> en die zou ik er op de een of andere manier moeten uitkrijgen.
Zoals reeds gezegd gebeurt dit met LTrim, LTrim of Trim.
In aanvulling hierop, en voor wie hier behoefte mocht aan hebben, post
ik een aantal functies die ook de linkse (leading) en/of de rechtse
(trailing) tabs er uit halen, en ook een functie om een zero-ended
Pascal of C string naar VB om te zetten. Dit laatste is vooral handig
bij het lezen van strings uit INI (profile) files.
Public Function LTrimTabSpaces(S As String) As String
Dim I As Long, L As Long, C As String
L = Len(S)
If L > 0 Then
For I = 1 To L
C = Mid(S, I, 1)
If (C <> " ") And (C <> Chr(9)) Then
LTrimTabSpaces = Right(S, L - I + 1)
Exit Function
End If
Next I
End If
LTrimTabSpaces = ""
End Function
Public Function RTrimTabSpaces(S As String) As String
Dim I As Long, L As Long, C As String
L = Len(S)
If L > 0 Then
For I = L To 1 Step -1
C = Mid(S, I, 1)
If (C <> " ") And (C <> Chr(9)) Then
RTrimTabSpaces = Left(S, I)
Exit Function
End If
Next I
End If
RTrimTabSpaces = ""
End Function
Public Function TrimTabSpaces(S As String) As String
TrimTabSpaces = RTrimTabSpaces(LTrimTabSpaces(S))
End Function
Function VBString(S As String) As String
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
' Input: a zero-ended Pascal or C-type profile string.
' Outpout: a VB string.
'
Dim I As Integer, Sn As String
I = InStr(1, S, Chr$(0))
If I > 0 Then Sn = Left$(S, I - 1) Else Sn = S
VBString = TrimTabSpaces(Sn)
End Function
--------------------
Met vriendelijke groeten,
Hugo Maes
Technical Details
Message-ID:
<3A192434.448B8570@Med.Kuleuven.Ac.be>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3a1905ca$0$4491$73bec57d@news.be.uu.net>Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit X-Google-Thread: 1147fd,3e70f162ae450957,start X-Google-Attributes: gid1147fd,public X-Google-Thread: fcea4,2207dde8d3874eb2 X-Google-Attributes: gidfcea4,public From: Hugo Maes <Hugo.Maes@Med.Kuleuven.Ac.be> Subject: Re: slotspaties uit een string halen (VB) Date: 2000/11/20 Message-ID: <3A192434.448B8570@Med.Kuleuven.Ac.be> X-Deja-AN: 695741925 Cache-Post-Path: marvin!unknown@n34pc12.med.kuleuven.ac.be Content-Transfer-Encoding: 7bit References: <3a1905ca$0$4491$73bec57d@news.be.uu.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@belnet.be X-Trace: naxos.belnet.be 974726176 16326 134.58.127.3 (20 Nov 2000 13:16:16 GMT) Organization: K.U.Leuven X-Cache: nntpcache 2.3.3 (see http://www.nntpcache.org/) Mime-Version: 1.0 NNTP-Posting-Date: Mon, 20 Nov 2000 13:16:16 +0000 (UTC) Newsgroups: be.comp.programming,kotnet.comp.programmeren