Results 1 to 8 of 8

Thread: Grrrr... need help...

  1. #1

    Thread Starter
    Lively Member Xero's Avatar
    Join Date
    Feb 2000
    Posts
    75

    Exclamation

    Is there anyway to get those big hollow boxes out of a string? Trim(string) doesnt work.

    Any help is greatly appreciated!

  2. #2
    Guest
    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

  3. #3
    Member
    Join Date
    Jul 2000
    Location
    BFE in Oregon
    Posts
    33
    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

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    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

  5. #5
    Guest
    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

  6. #6

    Thread Starter
    Lively Member Xero's Avatar
    Join Date
    Feb 2000
    Posts
    75
    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!

  7. #7
    Guest
    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!

  8. #8
    Guest
    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
  •  



Click Here to Expand Forum to Full Width