![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
|
|
#1 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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 SubThanks 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. |
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
What on earth possessed you to learn Visual Basic instead of something sane like VB .NET or C#?
|
|
|
|
|
|
#3 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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 |
|
|
|
|
|
#4 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
http://msdn.microsoft.com/vstudio/express/vb/
There ya go. VB .NET compiler. Now you have no excuse. :p |
|
|
|
|
|
#5 |
|
The Supreme Ruler
![]() Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6
![]() |
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 |
|
|
|
|
|
#6 |
|
Expert Programmer
|
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.
|
|
|
|
|
|
#7 |
|
Expert Programmer
|
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.
![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|