how can i get the little square out of my variable,you should know what i mean!!!!!!
Printable View
how can i get the little square out of my variable,you should know what i mean!!!!!!
Maybe we should, but until we actually do, we can't answer. :rolleyes:
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
sorry for the insult Yonatan,but anyway what $ mean
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. :rolleyes:
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!
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.
I'm assuming HeSaidJoe's code doesn't correctly cut the nulls. (Didn't see that code, just assuming)
Try this:
Enjoy! :rolleyes: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
tank u now it work
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?
Do not use GetSystemDirectory. Use GetSysPath which is exactly the same as GetWinPath except it gets the System directory. :rolleyes:
Enjoy! :rolleyes: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
Cool code sections:
[code]
' My code goes here
[/code]
Result:
Code:' My code goes here
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.
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? :rolleyes:
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..