check the combobox value

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
kitty
Newbie
Posts: 2
Joined: Thu Jan 14, 2010 8:44 am

check the combobox value

Post by kitty » Tue Jan 19, 2010 3:56 am

hi,

i am wondering how to check the value in ComboBox.

the test step:
1.insert the data
2.check the data in the combox
3.delete the data
4.i wanna to check if the data has been deleted.
so could anyone tell me?

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Tue Jan 19, 2010 4:15 am

Hi Kitty,

What do you mean by check the data? Are you wondering how to grab the value of something that was selected in a combobox?

Also when you say delete the data, are you referring to clearing the values that you have in the combobox? Please provide a few more details as to what your doing or if you have the beginnings of a script feel free to post that too =)

kitty
Newbie
Posts: 2
Joined: Thu Jan 14, 2010 8:44 am

Post by kitty » Tue Jan 19, 2010 5:24 am

sarver311 wrote:Hi Kitty,

What do you mean by check the data? Are you wondering how to grab the value of something that was selected in a combobox?

Also when you say delete the data, are you referring to clearing the values that you have in the combobox? Please provide a few more details as to what your doing or if you have the beginnings of a script feel free to post that too =)
hi,
i have no beginning script.i am wondering how to grab the value of something that was selected in the combobox?
could u pls tell me something? thanks!

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Tue Jan 19, 2010 8:46 am

Hi Kitty,

When using a combobox you need to make sure you use the command getdialogaction. This is what requests what variables have been selected and in this case which item from your combobox was selected.

For example, in your dialog, if you have a combo box named mscombobox1 and a dialog named Dialog1 one, when you choose something from that combobox and then issue the command getdialogaction>dialog1 Your value will then show up in the variable dialog1.mscombobox1.

I have created an example script to help illustrate this. I would also highly recommend using the debugger to go through the script line by line and you can watch as the values get filled in after certain commands are issued.

Code: Select all

//the dialog with the combo box and the query button
Dialog>Dialog1
   Caption=Dialog1
   Width=445
   Height=250
   Top=116
   Left=20
   ComboBox=msComboBox1,48,40,145,Item 1%CRLF%Item 2%CRLF%Item 3%CRLF%Item 4%CRLF%Item 5
   Button=Combo Value Lookup,48,88,115,25,22
   Label=Click the button below to see what was selected,48,69,true
   Label=Choose an Item from the Combo Box Below,53,20,true
EndDialog>Dialog1


show>dialog1

//this loop runs and waits for you to press the button
label>actionloop
Getdialogaction>dialog1,r
wait>.2

//When the button is pressed it sets the results value or "r" to 22 and runs the subroutine
if>r=22
gosub>combovaluelookup
endif

goto>actionloop


srt>combovaluelookup
resetdialogaction>dialog1

//this command is what pulls all the values from the dialog and in this case whatever you chose from the combobox
getdialogaction>dialog1,r

//this is an example of how you can use the value you pulled
messagemodal>The item you chose was %dialog1.mscombobox1%

//This is another useful variable, the entire list of values that are in the combobox
messagemodal>The entire list of items is %CRLF%%Dialog1.Mscombobox1.items.text%
END>combovaluelookup
I hope this helps, let me know! =)

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 » Tue Jan 19, 2010 1:39 pm

Where is this combo box whose value you are trying to capture?

Is it on a web page?
Is it on a database program or some specific application?
Is it on some type of form?
Is it in a Macro Scheduler Dialog?

Can you be more speciifc about what is happening overall and what you are trying to do? Why are you capturing this combobox value, and what are you going to do with the captured value?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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