Results 1 to 14 of 14

Thread: the *!@%^$# square

  1. #1

    Thread Starter
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606

    Angry

    how can i get the little square out of my variable,you should know what i mean!!!!!!

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Maybe we should, but until we actually do, we can't answer.

  3. #3
    Guest
    I assume that you have non-printing character in the middle of your data.

    by Brute force, you can get rid of it and any string of unwanted characters:

    newdata=left$(oldata,pos_of_unwanted-1)
    & right$(olddata,len(olddata) -
    (pos_of_unwanted+len(unwantedstring)-1)


    I think you can also use replace by setting the unwanted character(s) to "", but I've never used it myself.


    Good Luck
    DerFarm

  4. #4

    Thread Starter
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606

    Red face common

    sorry for the insult Yonatan,but anyway what $ mean

  5. #5
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892

    Question I'm still not sure what this thread is about!

    The $ sign means the specified function returns a String.
    There's also % for Integer, & for Long, etc.

    It's more fun to type As <VarType>, in my opinion.

  6. #6

    Thread Starter
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606

    the subject is.........

    i get in my string variable(in the win path:HeSaidJoe gave me the code to find the win path)little blank square and when i try to put:
    win_path=win_path & "something"
    msgbox win_path

    i don't see the something!

  7. #7
    Addicted Member
    Join Date
    May 2000
    Location
    Grand Rapids, MI
    Posts
    231
    I assume yer talking about the box, that is shown when you are trying to display a non-visual or non-ascii character in a string, such examples are Carridge Returns, LineFeeds, etc that in places like textbox(With multiline turned off) will show as a box, you could try searching and removing things like vbcrlf vbcr vblf vbtab

    stuff that might show up as a block in viewers that dont respond to those types of character feeds.
    -Karl Blessing aka kb244{fastHACK}
    [email protected]

  8. #8
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    I'm assuming HeSaidJoe's code doesn't correctly cut the nulls. (Didn't see that code, just assuming)
    Try this:
    Code:
    Option Explicit
    
    Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    
    Private Const MAX_PATH = 260
    
    Function GetWinPath() As String
        Dim lPos As Long
        
        GetWinPath = String(MAX_PATH, vbNullChar)
        Call GetWindowsDirectory(GetWinPath, MAX_PATH)
        
        lPos = InStr(GetWinPath, vbNullChar)
        If lPos > 0 Then GetWinPath = Left(GetWinPath, lPos - 1)
        
        If Not Right(GetWinPath, 1) = "\" Then GetWinPath = GetWinPath & "\"
    End Function
    Enjoy!

  9. #9

    Thread Starter
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606

    Lightbulb yessssssssssss

    tank u now it work

  10. #10
    Lively Member
    Join Date
    Sep 2000
    Location
    NC, USA
    Posts
    102

    Question Hey wait a second?????

    Ok Yonatan, you got it working, great but....

    sebs, I found the old thread and you asked for the system32 directory, these all return the windows directory, below is a different decleration that returns the sysytem path.

    Yonatan or anyone else,
    What gives with this? Below is some code. if you run the first one (slightly modified) oringinally from HiSaidJoe. it will not let you append any string info to it? While the next one (again slightly modified) oringinally from Yonatan will allow appended strings??? why is that? what is going on?

    Thanks,
    KillemAll

    <----------Begin Code------------>
    Option Explicit
    Private Const MAX_PATH = 260
    Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long

    Private Sub Command1_Click()
    Dim strFindWinDir$, WinDir$
    WinDir$ = Space(144)
    strFindWinDir$ = GetSystemDirectory(WinDir$, 144)
    WinDir$ = Trim(WinDir$)
    WinDir$ = WinDir$ & "\Filename.ext"
    MsgBox "The Windows Directory Path is: " & WinDir$
    End Sub

    Private Sub Command2_Click()
    Dim lPos As Long, getwinpath As String
    getwinpath = String(MAX_PATH, vbNullChar)
    Call GetSystemDirectory(getwinpath, MAX_PATH)
    lPos = InStr(getwinpath, vbNullChar)
    If lPos > 0 Then getwinpath = Left(getwinpath, lPos - 1)
    If Not Right(getwinpath, 1) = "\" Then getwinpath = getwinpath & "\"
    getwinpath = getwinpath & "Filename.ext"
    MsgBox "The Windows Directory Path is: " & getwinpath
    End Sub
    <----------End Code------------>


    Btw, how do yall do those cool, code sections?

  11. #11
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Do not use GetSystemDirectory. Use GetSysPath which is exactly the same as GetWinPath except it gets the System directory.
    Code:
    Option Explicit
    
    Private Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    
    Private Const MAX_PATH = 260
    
    Function GetSysPath() As String
        Dim lPos As Long
        
        GetSysPath = String(MAX_PATH, vbNullChar)
        Call GetSystemDirectory(GetSysPath, MAX_PATH)
        
        lPos = InStr(GetSysPath, vbNullChar)
        If lPos > 0 Then GetSysPath = Left(GetSysPath, lPos - 1)
        
        If Not Right(GetSysPath, 1) = "\" Then GetSysPath = GetSysPath & "\"
    End Function
    Enjoy!

    Cool code sections:

    [code]
    ' My code goes here
    [/code]

    Result:
    Code:
    ' My code goes here

  12. #12
    Lively Member
    Join Date
    Sep 2000
    Location
    NC, USA
    Posts
    102

    Thx

    Thx for the code thing Yonatan, You're "The Man". I still don't understand why the first way wont let you append text? I am guessing it has something to do with there being a null character at the end or something? but I guess as long as it gets the job done.

  13. #13
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Yes, it is because of the null.

    Just use my functions. They accept any path size up to maximum size (MAX_PATH), trim the nulls and even add a backslash to the end. What more could you want?

  14. #14
    Lively Member
    Join Date
    Jul 2000
    Posts
    70

    Filesystemobject from asp.dll..

    If you dare to attach another tail to your code like asp.dll you could use filesystemobject model for file handling.. Just a bare idea..
    Kiziltan Yuceil
    Freelance Web/VB/VBA Programmer
    "It's not what you know it's to whom you consult and with whom you collaborate"

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