listbox

  • Thread starter Thread starter Pierre
  • Start date Start date
P

Pierre

hey, first of all, many thx 4 the help

this is my problem, i'm saving names in a listbox. just names, nothing
more, now i wanna take the first name out of the listbox (for saving
purpose in a Database), so i want to take the name at the first index.
now how do i do that. i wanna read the first name and than delete it.
how do i do that. the adding part of the names was easy, but the
retrieving part is hard.

this is the adding part
Private Sub txtnaam_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles txtnaam.KeyPress
Dim dummy As Char
Dim succes As Boolean
Dim geboortedatum As Date

dummy = e.KeyChar
If dummy = Chr(13) Then
lst_namen.Visible = True
lst_namen.Items.Add(txtnaam.Text)
Do
geboortedatum = Date.Parse(InputBox("Geef de Geboorte
Datum in", "GeboorteDatum", "1/1/1900"))
If geboortedatum > System.DateTime.Today Then
MsgBox("Een fout jaar , geef de juiste geboorte datum
in!!", MsgBoxStyle.Exclamation, "Foute Geboortedatum")
succes = False
Else
succes = True
End If

Loop Until succes = True
lstGebDatum.Items.Add(geboortedatum)
txtnaam.Text = vbNullString
txtnaam.Focus()
End If
End Sub

but how can i get the first item from the list?
i've got
lstgebdatum.selectindex = 0
but than?

thx a lot , hope i've described my problem clearly.
 
Hi Pierre,
but how can i get the first item from the list?

All items are stored in the "Items"-Property, as a list of objects. You
could do something like:

Dim s as String = CStr(lstNames.Items(0))

Regards,

Frank Eller
www.frankeller.de
 
Back
Top