|
-
Jun 4th, 2000, 01:12 AM
#1
Thread Starter
New Member
Ok, I am writing a program that will check a text box and see if it is a valid file to execute. I have a text box and a command button. My method is to use the Left() function and when you click on the command button, what it will do is it will check to see that the text box contains a valid file extension.
So lets say, a valid file name i call ends with .exe
the text box reads c:\example\test.exe
with my program, the left() will hold "exe" part and since that i have already defined as a valid file extension, it will execute it. If lets say the text box read:
c:\example\test.jpg
it will not execute it.
So, this is my code"
Dim strCheck As String
strCheck = Left(txtFile.Text, 3)
And i know this should work, because i have used LEFT function. But now, on my Visual Basic 6 Ent. Edition, it doesn't work. Like after I type in Left( a popup thing should come up indicating i should type in a string and an integer. But that does not happen. And it doesn't work.
Anyone know what i am talking about? if you do, plz help. i'd greatly appreciate it. thanks.
-
Jun 4th, 2000, 01:34 AM
#2
Well, to get at the last three characters of your string, you want to use the Right() or Right$() function and not Left(). But I too have noticed that IntelliSense (that's what it's called) doesn't work for the Left or Left$ functions.
-
Jun 4th, 2000, 01:37 AM
#3
Fanatic Member
Almost there...
First off, you want to use the "Right()" function rather than "Left()". Left() will read left to right, whereas Right() will read right to left.
As for the "popup thing", it doesn't show up on the right and left functions when you are setting something equal to it as you are in your code. Also you may want to consider the fact that the extension could be 2 characters long (as in .js) in that case you could use code like below...
Code:
Private Sub Command1_Click()
Dim strCheck As String
Dim tArray
tArray = Split(txtFile.Text, ".")
strCheck = tArray(UBound(tArray))
MsgBox strCheck
End Sub
That way it doesn't matter how long the extension is. Anyways, it was just a thought.
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
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
|