Form information from Combobox to string

Mark Douglas

Member
Joined
Mar 29, 2006
Messages
9
Programming Experience
Beginner
This is probably a super easy question, and I've searched the forms so I'm stuck probably because its so basic. Sorry. :confused:

So I made a basic form, that I'm writing to an excel file. Well I enter the information into the Combobox hit my GO button to write the information to the excel file.

Well in the excel file I get this. System.Windows.Forms.ComboBox, Items.Count: 2

When it should be the string from the combobox. Here is the code I'm using.

xlSheet.Cells.Item(1, 1) = ListBox1 I think the = Listbox1 is where I'm off right?

This is what I've been doing in VBA. Hence where I think I'm going about this all wrong.

Thanks for any help!!
 
Just for future reference. A list box is an object in vb.net so therefore if you try to pass it like you did in VBA it won't work. .Text is a member of listbox which inturn is a member of listcontrol then control etc.... VBA differs greatly from vb.net becaus it isn't truely object oriented. Next time you come accross a problem like this think about what you are doing in terms of an object.

Glad i could help.
 
I know i used VBA extensively when i first started out. But if you think about it vb.net makes more sense. I.e

VB.NET:
VBA
 
Me.textbox1 = me.textbox2

Now really what that should be trying to do is 'turn' textbox1 into textbox2, because it is a reference to the actual control. Whereas..

VB.NET:
VB.Net
 
Me.textbox1.text = me.textbox2.text
See what i mean?
 
Sweet...The .text seemed to work out. I think I need to keep going through peoples examples to figure this out a little more.

Thanks for the help!!
 
Back
Top