|
-
Sep 28th, 2000, 12:40 PM
#1
Thread Starter
Frenzied Member
how can i get the little square out of my variable,you should know what i mean!!!!!!
-
Sep 28th, 2000, 12:44 PM
#2
Guru
Maybe we should, but until we actually do, we can't answer.
-
Sep 28th, 2000, 12:46 PM
#3
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
-
Sep 28th, 2000, 12:51 PM
#4
Thread Starter
Frenzied Member
common
sorry for the insult Yonatan,but anyway what $ mean
-
Sep 28th, 2000, 12:57 PM
#5
-
Sep 28th, 2000, 01:01 PM
#6
Thread Starter
Frenzied Member
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!
-
Sep 28th, 2000, 01:17 PM
#7
Addicted Member
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.
-
Sep 28th, 2000, 01:42 PM
#8
Guru
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!
-
Sep 28th, 2000, 01:47 PM
#9
Thread Starter
Frenzied Member
yessssssssssss
-
Sep 28th, 2000, 02:00 PM
#10
Lively Member
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?
-
Sep 28th, 2000, 02:06 PM
#11
Guru
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
-
Sep 28th, 2000, 02:14 PM
#12
Lively Member
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.
-
Sep 28th, 2000, 02:50 PM
#13
Guru
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?
-
Sep 28th, 2000, 04:37 PM
#14
Lively Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|