Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jan 14th, 2006, 9:40 PM   #1
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Simple question on list boxes

I decided to learn VB today because of the ease of creating appealing guis with it. So far, I've liked what I've seen.

Normally, when I learn a new language I don't read a book cover to cover. I simply don't have the patience to do it. I know if I try this that I will simply end up losing interest and giving up on it, so I decided that I would make a Cross-country flight planner as my first project in VB. Haven't had any problems with it really, but I ran across something which I didn't quite understand.

I'm using a list box to display all the data that the user enters for me. I'm having a problem adding to the list box, though . . .

I can't add a variable. I have a string called strDeparture declared and initialized, and when I try adding that to the list box it doesn't quite work how I expected.

The statement:

lstCheckpoints.AddItem strDeparture

fails, however if I use:

lstCheckpoints.AddItem "" & strDeparture

it works. Any idea why this is. I'll paste my whole code so far (not very much) in case it helps you out any.

Dim strDeparture As String

Private Sub btnAddCheckPoint_Click()
If (strDeparture = "") Then
	strDeparture = InputBox("Please enter the name of the departure airport.", _
		"Departure Airport")
	lstCheckpoints.AddItem "" & strDeparture
Else
	frmCheckpoint.Show
End If
End Sub

Private Sub Form_Load()
Dim strTitle As String
strTitle = InputBox("Please enter the title of the cross country flight", "Title")
XCPlanner.Caption = strTitle

End Sub

Private Sub Picture1_Click()

End Sub

Thanks in advance for any help.

Edit: Furthermore, is it possible to get the list box to add items from left to right rather than fron top to bottom?
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower

Last edited by Mjordan2nd; Jan 14th, 2006 at 10:05 PM.
Mjordan2nd is offline   Reply With Quote
Old Jan 15th, 2006, 8:54 AM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
What on earth possessed you to learn Visual Basic instead of something sane like VB .NET or C#?
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 15th, 2006, 12:01 PM   #3
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
I have a VB6 book (not a good one, but meh) and compiler.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Jan 15th, 2006, 12:27 PM   #4
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
http://msdn.microsoft.com/vstudio/express/vb/

There ya go. VB .NET compiler. Now you have no excuse. :p
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Old Jan 15th, 2006, 2:08 PM   #5
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Jesus, it's free? Wish I'd known that. -_-

Thanks, Ooble.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Jan 15th, 2006, 2:13 PM   #6
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
Yeah the express editions are all free. Pretty cool.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Jan 15th, 2006, 6:23 PM   #7
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
All that seems to be the difference between strDeparture and "" & strDeparture is that the latter is implicitly typecast as a string. Why that makes any difference since strDeparture is already declared as a string in class context is a mystery: you could try declaring it Private instead, turn Option Explicit on or switch to VB.NET.
Rory is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 12:42 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC