Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > getting data from a listbox control...


Reply
 
Thread Tools Display Modes
  #1  
Old 03-06-2003, 07:48 AM
Jawbreaker4Fs's Avatar
Jawbreaker4Fs Jawbreaker4Fs is offline
Freshman
 
Join Date: Dec 2002
Location: Mechanicsburg, PA, USA
Posts: 41
Default getting data from a listbox control...


I know this is probably something that's insanely easy.. but I can't seem to figure it out for the life of me! see... I need to set a string equal to a certain member of a listbox control. For example... say I have the following values in my listbox, named list1:

this
is
my
program

how would I set a string... say, strtemp, to be equal to "my", the third item of the listbox control?

now... I was thinking it would be something like...

strtemp = list1.datamember(3), but that isn't working :-/ anyone have any idea how this can be done correctly?
Reply With Quote
  #2  
Old 03-06-2003, 08:08 AM
Garmour's Avatar
Garmour Garmour is offline
Back for a little while..

Retired Leader
* Expert *
 
Join Date: Oct 2002
Location: Behind you.....Boo
Posts: 2,199
Default

MsgBox List1.List(List1.ItemData(3))
__________________

....but then, what would I know ?
Reply With Quote
  #3  
Old 03-06-2003, 09:34 AM
Squirm's Avatar
Squirm Squirm is offline
Political Coder

Retired Moderator
* Guru *
 
Join Date: Mar 2001
Location: London, England
Posts: 8,037
Default

Code:
'Retrieving list items:
Dim i As Integer

For i = 0 To List1.ListCount - 1
    Debug.Print List1.List(i)
Next i

'What you want:
Dim strtemp As String

strtemp = List1.List(2)
__________________
Search the forums | Use [vb][/vb] tags | Still IRCing
Reply With Quote
Reply


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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
MsFlexGrid & VBA msl Word, PowerPoint, Outlook, and Other Office Products 2 09-17-2006 03:21 PM
multi connections, one port? burningodzilla Communications 5 08-02-2005 05:04 PM
To bind your data to a data control, or to write your all the code yourself? Stewie Database and Reporting 14 11-07-2002 10:38 AM
WinSock vbsupernewbie Communications 1 09-12-2001 10:20 PM
Control Arrays: What, Why and How BillSoo Tutors' Corner 0 07-13-2001 12:46 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->