List Box Help - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

List Box Help

In a list box, i am showing the date, level, and score a child achieved on my game. How can i have the list box showing details in this format:
Date=4/2/05
Level=3
Score=2

rather than this:
Date=
4/2/05
Level=
3
Score=
2

I think the basic question is, can i merge two items, into one value on the list?
Please help someone, i'm still fairly new to the vb arena!

Comments

  • the walrusthe walrus Posts: 249Member
    [b][red]This message was edited by the walrus at 2005-2-6 15:32:25[/red][/b][hr]
    if you posted your code i could show you where you're going wrong for certain, but my guess is that you're doing something like

    [code]
    List1.AddItem "Date="
    List1.AddItem Date
    List1.AddItem "Level="
    List1.AddItem Level
    List1.AddItem "Score="
    List1.AddItem Score
    [/code]

    if so, change your code so that it looks like this

    [code]
    List1.AddItem "Date=" & Date
    List1.AddItem "Level=" & Level
    List1.AddItem "Score=" & Score
    [/code]

    of course using your variable names instead of mine :). a note on what & means. & is vb's string concatenator. you may also see people concatenate strings with the + symbol, which works fine if the two things you are combining are both strings. the reason vb allows you to concatenate strings with + is for backwards compatability--in old versions of basic there was no & operator and + was the only way to concatenate strings. the problem with + is it's also used for addition and you can run into problems if you're not careful with it. something like [b]digit1 + digit2[/b], where digit1 is 3 and digit2 is 5, will obviously add the two numbers together and return 8, where as [b]digit1 & digit2[/b] will convert both variables into strings and then concatenate them, returning "35" instead of 8. this is very important because you may not always know the type of data you're working with, so using & as a string concatenator rather than + is a good habit to get into.


  • nickhudson4evanickhudson4eva Posts: 2Member
    Thankyou very much, I tried something similar earlier today, but with no success, although I was using + instead of &. Now it works fine.

    Thanks again
Sign In or Register to comment.