|
-
Sep 24th, 2000, 07:18 PM
#1
Thread Starter
Lively Member
Is there anyway to get those big hollow boxes out of a string? Trim(string) doesnt work.
Any help is greatly appreciated!
-
Sep 24th, 2000, 07:23 PM
#2
I think they could be a Chr(13) or Chr(10), just check if the end of the string contain either one and then take it out of the string.
Sunny
-
Sep 24th, 2000, 07:23 PM
#3
Member
Which big hollow box?
Is it one of the standard characters like the carriage return or line feed?
And does it happen every time?
Can you give an example?
Can you tell us where you experience this and what control contains this.
Can we have a code sample?
Glacius Cool
Concept Designer
VB5sp4,VC++6sp3
-
Sep 24th, 2000, 07:38 PM
#4
_______
<?>
Code:
Option Explicit
'replace function in VB6
'find an instance and replace it with another
' not sure what you want to get rid of
'this one gets rid of all spaces
Private Sub Form_Load()
Dim string1 As String, string2 As String
string1 = "my name is somewhere to be found!"
MsgBox string1
string2 = Replace(string1, " ", "")
MsgBox string2
End Sub
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Sep 25th, 2000, 03:25 PM
#5
Here is the VB5 eqv. of Replace().
Code:
Public Function Replace(sIn As String, sFind As String, sReplace As String, Optional nStart As Long = 1, Optional nCount As Long = -1, Optional bCompare As VbCompareMethod = vbBinaryCompare) As String
Dim nC As Long, nPos As Integer, sOut As String
sOut = sIn
nPos = InStr(nStart, sOut, sFind, bCompare)
If nPos = 0 Then GoTo EndFn:
Do
nC = nC + 1
sOut = Left(sOut, nPos - 1) & sReplace & _
Mid(sOut, nPos + Len(sFind))
If nCount <> -1 And nC >= nCount Then Exit Do
nPos = InStr(nStart, sOut, sFind, bCompare)
Loop While nPos > 0
EndFn:
Replace = sOut
End Function
-
Sep 26th, 2000, 03:25 PM
#6
Thread Starter
Lively Member
Code that generates those line feed or return characters(dont know which).
Code:
#!/usr/bin/perl
Public Function IniString(Heading As String, Key As String, File As String) As String
Dim ret As Long
Dim temp As String * 200
ret = GetPrivateProfileString(Heading, Key, File, temp, Len(temp), File)
If ret = 0 Then
Beep
Else
IniString = Trim(temp)
End If
End Function
Temp has extra of those up to 200 chars. I need to do this same thing(gets value from ini file) but with those damn return or line feed chars!
-
Sep 26th, 2000, 06:04 PM
#7
Try this piece'o'code...
Code:
Private Sub Form_Load()
Dim TestString As String
TestString = "This is a line " & vbTab & "with some 'hollow boxes'" & vbCrLf & " wich will be stripped soon..."
TestString = ETrim(TestString)
End Sub
Public Function ETrim(S As String) As String
'ETrim trims all "unknown chars" etc.. from a string
Dim T As Integer
Dim TmpS As String
TmpS = "" ' Clear Temporary String
For T = 1 To Len(S) ' Check all the in-string
If Asc(Mid(S, T, 1)) >= 32 Then TmpS = TmpS + Mid(S, T, 1) ' no weird stuff? Then add it to TmpS
Next T
ETrim = TmpS ' And return the value
End Function
Enjoy!
-
Sep 26th, 2000, 06:08 PM
#8
Originally posted by Xero
Code that generates those line feed or return characters(dont know which).
Code:
#!/usr/bin/perl
Public Function IniString(Heading As String, Key As String, File As String) As String
Dim ret As Long
Dim temp As String * 200
ret = GetPrivateProfileString(Heading, Key, File, temp, Len(temp), File)
If ret = 0 Then
Beep
Else
IniString = Trim(temp)
End If
End Function
Temp has extra of those up to 200 chars. I need to do this same thing(gets value from ini file) but with those damn return or line feed chars!
Those Hollow boxes are NULL (0) bytes. try this:
Code:
IniString = Trim(Left(temp, InStr(temp, Chr(0)) - 1))
And it'll work!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|