List box last element show in msgbox problem

  • (2 Pages)
  • +
  • 1
  • 2

24 Replies - 1278 Views - Last Post: 30 March 2013 - 11:39 AM Rate Topic: -----

#16 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,796
  • Joined: 26-March 09

Re: List box last element show in msgbox problem

Posted 30 March 2013 - 04:13 AM

no, I won't just give you the code, show me how you have tried to use the code I posted.

Me just giving you the exact code, won't help you learn anything.

Are you here to try and learn whilst solving your problem, or do you just want code giving to you?
Was This Post Helpful? 0
  • +
  • -

#17 mercy_angel  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 124
  • Joined: 28-February 13

Re: List box last element show in msgbox problem

Posted 30 March 2013 - 04:15 AM

Private Sub Command5_Click()
List3.List1.Item (List3.List1.Count)
End Sub


Was This Post Helpful? 0
  • +
  • -

#18 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,796
  • Joined: 26-March 09

Re: List box last element show in msgbox problem

Posted 30 March 2013 - 04:24 AM

OK, firstly, the code you have posted isn't the same as the code I posted.

Based on your first post, you said you wanted the last item from List1 and List2.

The code you have (shown below) to add an item to list3 is correct.

 list3.AddItem ItemToAdd 


You need to use the code I posted earlier. Modify it to use List1 or List2 instead of ListView1, then replace ItemToAdd in the code above.

This post has been edited by maj3091: 30 March 2013 - 04:25 AM

Was This Post Helpful? 0
  • +
  • -

#19 mercy_angel  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 124
  • Joined: 28-February 13

Re: List box last element show in msgbox problem

Posted 30 March 2013 - 04:31 AM

I write like this
List3.AddItem = List1.listitems.Item(List1.listitems.Count)


but not work.
Was This Post Helpful? 0
  • +
  • -

#20 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,796
  • Joined: 26-March 09

Re: List box last element show in msgbox problem

Posted 30 March 2013 - 04:42 AM

Why have you added an = sign?
Was This Post Helpful? 0
  • +
  • -

#21 mercy_angel  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 124
  • Joined: 28-February 13

Re: List box last element show in msgbox problem

Posted 30 March 2013 - 04:49 AM

Oh yeah, what a stupid mistake. But not work again.
listitems


method or data members not found
Was This Post Helpful? 0
  • +
  • -

#22 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,796
  • Joined: 26-March 09

Re: List box last element show in msgbox problem

Posted 30 March 2013 - 04:51 AM

OK, one question....are you using a listview control or a standard listbox?

If it's a list box, then I have misled you and apologies for that.

Listbox, doesn't have a listitems property, so you would have got an error.

Code for listbox, is as below

List3.AddItem (List1.List(List1.ListCount - 1))

Was This Post Helpful? 0
  • +
  • -

#23 mercy_angel  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 124
  • Joined: 28-February 13

Re: List box last element show in msgbox problem

Posted 30 March 2013 - 05:30 AM

Thanks :)
But I want to in one line show result, when I write
List3.AddItem (List1.List(List1.ListCount - 1))
List3.AddItem(List2.List(List2.ListCount - 1))


Result is like:
Bread
4$

But I want to write Bread - 4$
Was This Post Helpful? 0
  • +
  • -

#24 maj3091  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 303
  • View blog
  • Posts: 1,796
  • Joined: 26-March 09

Re: List box last element show in msgbox problem

Posted 30 March 2013 - 05:42 AM

OK, then I'm sure you can work that one out for yourself.

If we look at what you already know.....

1. You know how to add an item to a list.

2. You know how to get data from a list.

What you need to know.....

1. How to join (or concatenate) strings.

Have a quick google on concatenating strings in VB6 - you will be surprised how simple it is.

You're almost there......
Was This Post Helpful? 0
  • +
  • -

#25 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 574
  • View blog
  • Posts: 2,989
  • Joined: 19-May 09

Re: List box last element show in msgbox problem

Posted 30 March 2013 - 11:39 AM

mercyangel, I'm coming to this post late, but it's clear to me that you have unreasonable expectations about everyone else's ability to help you. If you want someone to help you without explaining your problem, find a site with experts who are also psychics. There might be one somewhere.

Most of the back and forth on this thread has to do with your lack of ability to explain your problem, and taking out your frustrations on the people that are trying to help you is misguided. The reason that maj gave you help on a ListView instead of a ListBox is because nowhere did you say which you were using. As such, you have wasted his time as well as your own.

If you want to get good answers to your questions, then ask good questions, as andrew was attempting to explain to you when you made your rude and childish remarks. We don't have much tolerance for rudeness and childishness, and we have little or no tolerance for someone who is unwilling to attempt to solve his own problems. If you don't want to live by these rules, then perhaps it's best that you move on. If you do, then we're glad to help you as best we may.

This post has been edited by BobRodes: 30 March 2013 - 11:43 AM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2