|
-
Sep 7th, 2000, 01:36 PM
#1
Thread Starter
Hyperactive Member
When the string returned is ="", how can I know if user click on Cancel or let the text blank and click OK?
Ulises Vázquez
[size=1.7]Oracle DBA Certified Professioanl
Visual Basic 6 Developer
Crystal Reports Designer
[/size]
-
Sep 7th, 2000, 01:44 PM
#2
Frenzied Member
I'm not sure if you can tell, but why do you want to know that?
If you really need it you could make your own inputbox, it's not that hard!
If you give me one moment, maybe I'll find something for ya.
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 7th, 2000, 01:56 PM
#3
It's easy.
Code:
iBox = Inputbox("Don't enter anything.")
If iBox = "" Then
Msgbox "Text was left blank or Cancel was pressed."
Else
End If
[Edited by Matthew Gates on 09-07-2000 at 03:06 PM]
-
Sep 7th, 2000, 02:03 PM
#4
Frenzied Member
ghehe Matthew he wanted to know how you can tell the difference between Cancel and a blank Box
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 7th, 2000, 08:24 PM
#5
Frenzied Member
Here's an idea: make the default value a single space, so that the box appears blank, and if the user wants to submit nothing then they press OK and you get " " returned. If they press cancel you get "" returned. It's a bit of a dodgy method, might be useful though.
Harry.
"From one thing, know ten thousand things."
-
Sep 7th, 2000, 09:13 PM
#6
Addicted Member
the cancel proprity is
vb2
so :
Dim Result1 As String
try1:
Result1 = inputbox("What is your name ?","","")
If not Result1 = vb2 then
If not Result1 = "" then
'All is ok ..let's continue
else
a=msgbox ("you leave the box blank !",vbcritical,"ERROR")
goto try1
end if
else
end
end if
-
Sep 7th, 2000, 09:19 PM
#7
Frenzied Member
The InputBox function returns the string the user entered, or a zero-length string if they pressed cancel. It doesn't return a value of type VbMsgBoxResult.
Harry.
"From one thing, know ten thousand things."
-
Sep 7th, 2000, 09:25 PM
#8
Addicted Member
I alway use this method and that's alway's work very good..
an inputbox have the same result as a msgbox BUT dont contain any graphics ( I dont know how so ... ) .
-
Sep 8th, 2000, 11:28 AM
#9
Frenzied Member
Well you look in the help files then. The standard InputBox function returns a string. The VbMsgBoxResult type is just an Enum with values ranging from about 1 - 7, so if they enter a number in that range as a string and you compare it with a VbMsgBoxResult, the compiler will perform an implicit cast and compare the values. Possibly giving a weird result.
The return value can't be a VbMsgBoxResult and a string.
Harry.
"From one thing, know ten thousand things."
-
Sep 8th, 2000, 12:16 PM
#10
New Member
use that
dim sStrin as string
sString = InputBox("Your Text")
if Trim(sString)="" then
MsgBox "You enten nothing"
endif
-
Sep 8th, 2000, 12:32 PM
#11
Frenzied Member
Eortizr, please read the whole post, this is not what he want.
I think the idea of HarryW is by far the best! smart thinking man 
Code:
ibox = InputBox("Please enter something"," ")
If ibox = " " Then
'Ok was pressed and nothin' was filled in.
ElseIf ibox = "" Then
'Cancel was pressed
End If
All credits go to HarryW, I just made the example
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 8th, 2000, 12:41 PM
#12
Lively Member
Coding Practice
pro2, goto is shunned by most programmers. I would re-arrange that code you posted inside a 'do until' loop to keep popping the box up for input until the correct value is input.
Later
REM
"Innovate, don't immitate."
-
Sep 8th, 2000, 12:51 PM
#13
Frenzied Member
Yeah you're right REM, also pro2, never use end if it's not neccesary (< spellcheck?), instead, use
Code:
Unload <FORMNAME>
'like:
Unload Me
'or
Unload Form2
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Sep 8th, 2000, 12:59 PM
#14
Hyperactive Member
try this
aaron young gave me this one, a module he wrote to extend the input box. It includes a CancelError property, although I do not know how well that particular property works since i have yet to use it
http://forums.vb-world.net/showthrea...threadid=19628
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
|