martin2k

Home | Forums | Visual Basic 6.0 | Games | Web Directory | Software | HTML | Wiki | Blog | Contact

Combo1


Home Read and add posts to the Visual Basic 6.0 Forums Download some of my programs and OCXs Read the Tips here The old style forum is still available here Contact

Back


From: Ashes E-mail: A_R_Durham@Hotmail.com 1

Website: http://www.freemoneydome.com/

Subject: Combo1

Comments:

I want to use dropdown menus, but I don't know how the basic coding works. If it helps any, I know how to use Listboxes.
Acually, speaking about list boxes, how do you "setfocus" to a point and then have a text box show the same name and have it highlighted?
Thanks for your time,
Ashes
(I'm just starting senior years at school and i'm doing programming.)

From: Martin Allen E-mail: <No e-mail> 2

Subject: RE: Combo1

Comments:

Hello,

To add code to a dropdown menu, or a ComboBox as its properly called, at runtime, you can use these commands:

Private Sub Form_Load()
Combo1.AddItem "Item"
Combo1.AddItem "Item2"
End Sub

Combo1 is the name, and AddItem is the method. "Item" is the text to insert.

To set the selected item of a ComboBox or ListBox, type:

Combo1.ListIndex = 1
List1.ListIndex = 1

Where 1 is the location in the list (0 being the first item).

To set a TextBoxes text to that of which is in a ListBox,type:

Text1.Text = List1.Text

I hope this helps you and thank you for visiting my site.  Good luck in your studies.

http://www.martin2k.co.uk/vb6

Martin Allen

From: Ashes . E-mail: A_R_Durham@Hotmail.com 3

Subject: RE: Combo1

Comments:

Hey,

Well, I know most of that....well...only the adding part, butow to you get the combo box to do the command it is listed for?
For example: having a combobox for font sizes. if user clicks onsize 24, the font changes in the text1.text to 24.

Thanks

Ashes

From: Martin Allen E-mail: <No e-mail> 4

Subject: RE: Combo1

Comments:

Hello Ashes .,

To do that you need the following code:

Private Sub Combo1_Click()
Text1.FontSize = Combo1.Text
End Sub

Do you want this whole message to bwe put onto the Vb problems section of my web site so that others can learn from it?

Martin Allen
http://www.martin2k.co.uk/vb6

From: Ashes . E-mail: A_R_Durham@Hotmail.com 5

Subject: RE: Combo1

Comments:

Hey Martin,

It's up to you if you add our msg to your form. It would help heaps of people...but unfortunatly we are finished...sorry bout this but the font size works great.....but I can't do that for color. fore and back.

also, just say I had 2 forms and both forms have the same setter (Font size) and I wanted the list box on form1 to be the same as the combobox on form2 when you change it. meaning if Ichange the list box setting to 10, then I want the combobox on the next form to be changed to 10 as well.

Sorry to do this to ya...but I'm sorta desperate. Not just for the program I'm making, but for school too.

if you can help out once again, i'll be very greatful.

Thanks

Ashes

From: Ashes . E-mail: A_R_Durham@Hotmail.com 6

Subject: RE: Combo1

Comments:

Hey

the last email I sent with the subject of Re:Combo1 is wrong now. I figured out how to do half of that, but I still need to know how to do the color combo box.

ALSO.... Do you know the code for a cancel button, like on the "format" screen of Mircosoft Word?

Sorry again

Ashes

Sorry if this sent twice!

From: Martin Allen E-mail: <No e-mail> 7

Subject: RE: Combo1

Comments:

Hello again Ashes,

If you mean the combo box that has coloured boxes next to the text, you need the Image Combo, part of Microsoft Windows Common Controls 6.0(SP3) (MSCOMCTL.OCX).  I do not know how to use this control because I have never used it before.  If you have the MSDN Library CD, the help files on there will give you the necessary knowledge.  You need an Image Control (also part of Microsoft Windows Common Controls 6.0 (SP3)) to hold the images of the coloured boxes that will be used with the combobox (somehow).   Cancel buttons can have this code to hide the form:

Private Sub Command1_Click()
Me.Hide
End Sub

But I am unsure to what you mean by the "format" screen of Microsoft Word.

Martin

From: Ashes . E-mail: A_R_Durham@Hotmail.com 8

Subject: RE: Combo1

Comments:

Hey Martin

Thank you for the Cancel code. The format screen is "font" which is under format. sorry.

No, what I mean by colours is when you want to select a color with a combo box. the code"text1.forecolor=combo1.forecolor" OR"text1.forecolor=combo1.text" works. The pictures next to the font come later, i know how that one works...But how do you acually get it to change the colors?

thanks again

Ashes

From: Martin Allen E-mail: <No e-mail> 9

Subject: RE: Combo1

Comments:

Hello Ashes,

Here is one way to do what you want:

Look at this picture http://www.martin2k.co.uk/vb6/exes/fc.gif

You will see that there is a list with colours in, copy this in a combobox, using the same case e.g. 'Red' instead of 'red' (the full list of valid colours are here http://www.martin2k.co.uk/vb6/ocxs/allenocx.txt).  Download this OCX - http://www.martin2k.co.uk/vb6/ocxs/allenocx.zip and put it on to your form.  When someone chooses a colour on the combo box, use this code:

Private Sub Combo1.Click()
Text1.ForeColor = Allen1.ColConv(Combo1.Text)
End Sub

I hope this is what you wanted to know!  Your message and all the replies have been added to my web site.

Martin Allen
http://www.martin2k.co.uk/vb6

From: Ashes . E-mail: A_R_Durham@Hotmail.com 10

Subject: RE: Combo1

Comments:

Hey

Sorry, but how do you acually put in to my form? This stuff is a little out of my league, but please continue. Your probably sick of me now, sorry.

Ashes

From: Martin Allen E-mail: <No e-mail> 11

Subject: RE: Combo1

Comments:

Hello Ashes,

To put the Allen OCX tool on to the form, first download it from here:

http://www.martin2k.co.uk/vb6/ocxs/allenocx.zip

Unzip the file and put it into C:\WINDOWS\SYSTEM.

When you open Visual Basic, right-click on the Toolbox and click on Components... Put a tick next to Allen OCX and click OK. Click on the Allen OCX icon in the toolbox and put it on the form like you would any control e.g. ListBox.

Make a ComboBox with a list of colours (see the text file that comes with AllenOCX) amd a TextBox.

Then put in the following code:

Private Sub Combo1.Click()
Text1.ForeColor = Allen1.ColConv(Combo1.Text)
End Sub

Martin Allen http://www.martin2k.co.uk/vb6

From: fredy E-mail: fredydanilo@aol.com 12

Date: Wednesday, June 13, 2001 at 03:14:13

Subject: RE: Combo1

Comments:

How do i create a dropdown combo box in which i can select any of the seven days of the week. 
 Ex: Monday
     Tuesday
     Wednsday
     Thrusday
     Friday 
     Saturday
     Sunday

From: Martin Allen E-mail: <No e-mail> 13

Date: Monday, June 18, 2001 at 20:58:46

Subject: RE: Combo1

Comments:

There are 2 ways of doing this - once at design time and another at runtime.

To do this in design time - put a ComboBox onto the form and go to the ComboBoxes List property.  Write in the days and press Ctrl+Enter for carriage returns.

To do this at runtime, use the following code:

Private Sub Form_Load()
Combo1.AddItem "Monday"
Combo1.AddItem "Tuesday"
Combo1.AddItem "Wednesday"
Combo1.AddItem "Thursday"
Combo1.AddItem "Friday"
Combo1.AddItem "Saturday"
Combo1.AddItem "Sunday"
End Sub

This forum is no longer taking new messages or replies since 01 November 2002.  The above material is for reference purposes only.

The new Visual Basic 6.0 forum can be found here.


Martin Allen 1999 - 2006.  Last updated Saturday 15 July 2006 12:34:01 AM +0100.