Vb Cancel button

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Vb Cancel button

Post by Jmac2501 » Wed Nov 16, 2005 11:26 pm

I need to know how to make the cancel button do what i want. I am not tp good with VB yet just learning but here is what i have:

Vbstart
Function GetSerNum

GetSerNum = InputBox("Enter Your Serial Number : ")

End Function
vbend

VBEval>GetSerNum,sernum

///rest of script

I just copyed the example from the Vbsample script so i don;t know how to program button to do what i want them to do. Any help thanks.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Nov 16, 2005 11:52 pm

What are you trying to do overall?

Do you need to use VB?
Can't you just use Macro Scheduler commands?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Jmac2501
Pro Scripter
Posts: 76
Joined: Tue Nov 15, 2005 8:11 pm

Post by Jmac2501 » Thu Nov 17, 2005 3:29 pm

Well I need a place to where you can scan in a number and this works perfict but the cancel button works just like the ok button. so no i don't think script commands will work. the way it is set up works but i was just wanting to make it work better by if you use the cancel button it cancels.

User avatar
Marcus Tettmar
Site Admin
Posts: 7391
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Nov 17, 2005 4:16 pm

From the VBScript documentation:

"If the user clicks OK or presses ENTER, the InputBox function returns whatever is in the text box. If the user clicks Cancel, the function returns a zero-length string ("")."

So, you can just check for an empty string:

Vbstart
Function GetSerNum
GetSerNum = InputBox("Enter Your Serial Number : ")
End Function
vbend

VBEval>GetSerNum,sernum
If>{%sernum%=""}
MessageModal>Nothing was entered
Endif


Get the VBScript documentation from:
http://www.mjtnet.com/resources.htm

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts