PDA

Click to See Complete Forum and Search --> : another question...listbox help


funkheads
Nov 30th, 1999, 08:27 AM
ok. i am working on an alarm program and i need to use listboxes to set the time. here is what my interface look like:

http://www.mikey-d.com/view/tyme_listboxes.jpg

what i need to do is use the listboxes to scroll to a certain hour, minute, and second. then i need to place the "time" in a text box. but i want to be able to place it without having to select the item (number) in the listbox. is there any way to say

textbox.text = "the number that is showing in the window" ???

here is my code so far:


Dim h As String
Dim m As String
Dim s As String
Dim ap As String
h = lstHour.Text
m = lstMin.Text
s = lstSec.Text
If optAM.Value = True Then
ap = "am"
ElseIf optPM.Value = True Then
ap = "pm"
End If
txtTime.Text = h & ":" & m & ":" & s & " " & ap


i have the AM and PM parts taken care of. i assume i need to change lst"whatever".text to something else. am i making any sense? if not, let me know and i will try to help with further explanation. any help will be greatly appreciated. thank you.

--michael

XMortal
Nov 30th, 1999, 08:37 AM
well, first of all, wat sort of listbox is that? it doesnt look like a standard listbox, is an added component??

also, you might try the list1box change event?

i found an interesting way of doing it is to put in the got focus event a temp variable to store wat the field is, and then on the lost focus check if the data has changed and update the necessary variables

(i know there is the change event, but if you want it to change three or four times before you like wat you get ie incrementing or typing more than one char it helps)

also why does it have to be a listbox?? whats wrong with a textbox?

and how are you incrementing the hours and mins so they dont clock over 24 or 60?

hope these thoughts help, sorry if it is just causing more problems > ;)

funkheads
Nov 30th, 1999, 09:16 AM
well, it is a normal listbox just shrunk down to be the size of one "selection".

anyway, i have pre-populated the list box with the numbers 1-12 or 1-59 (depending on hours, mins, or secs) and i have to use listboxes because that's what the assignment is all about. my teacher says so. but i will try your idea about the got/lost focus. i think that might work. but any other suggestions from you or other people will still be appreciated, just in case it doesn't work.

thanks again.

--michael

Aaron Young
Dec 1st, 1999, 01:59 AM
Create a Listbox Control Array, (Create a Listbox Called lstTime and set the Index Value to Zero, then Copy and Paste it Twice More), a Textbox - txtTime and a Checkbox - chkAMPM..

Private Sub Form_Load()
Dim iIndex As Integer
For iIndex = 0 To 59
If iIndex < 12 Then lstTime(0).AddItem Right("00" & iIndex + 1, 2)
lstTime(1).AddItem Right("00" & iIndex, 2)
lstTime(2).AddItem Right("00" & iIndex, 2)
Next
End Sub

Private Sub lstTime_Scroll(Index As Integer)
txtTime = _
lstTime(0).List(lstTime(0).TopIndex) & ":" & _
lstTime(1).List(lstTime(1).TopIndex) & ":" & _
lstTime(2).List(lstTime(2).TopIndex) & ":" & _
IIf(chkAMPM, " PM", " AM")
End Sub

Private Sub chkAMPM_Click()
lstTime_Scroll 0
End Sub


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net