English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hey!

So I'm pretty stuck here :P
I have asked at IRC, Googled etc.

The thing is:

I have a Text-Box. I've called the Text-Box: txtTime
At "Form_Load" I have: txtTime.Text = Time

This give me the same time as my task-bar show me in the
Text-Box.

- So -
I've added a Combo-Box wich show the following:
---------------
| 2 Hours |
| 4 Hours |
| 6 Hours |
---------------

- So -
If I select "2 Hours" from the Combo-Box, I want the
Text-Box to show me the time now, pluss two hours.

If the time now is: 10:00, I want it to show me 12:00

- I hope you get my problem.
... Because it wasn't as easy as I thought it'd be! :P

I really appriciate ANY answers.


- Pjott

2007-01-11 09:53:01 · 3 answers · asked by dj.pjott 1 in Computers & Internet Programming & Design

3 answers

Look up time functions in the help file.

2007-01-11 10:07:24 · answer #1 · answered by Richard H 7 · 0 0

Private Sub Combo1_Click()
If Combo1.Text = "2 hours" Then
Text1.Text = CStr(CInt(Replace(Left(CStr(Time()), 2), ":", "")) + 2) & ":" & Right(CStr(Time()), 7)
End If

If Combo1.Text = "4 hours" Then
Text1.Text = CStr(CInt(Replace(Left(CStr(Time()), 2), ":", "")) + 4) & ":" & Right(CStr(Time()), 7)
End If

If Combo1.Text = "6 hours" Then
Text1.Text = CStr(CInt(Replace(Left(CStr(Time()), 2), ":", "")) + 6) & ":" & Right(CStr(Time()), 7)
End If
End Sub


Private Sub Form_Load()
Combo1.AddItem "2 hours"
Combo1.AddItem "4 hours"
Combo1.AddItem "6 hours"
End Sub

2007-01-12 06:19:53 · answer #2 · answered by simple_man 1 · 0 0

try:

TextBox.Text = DateAdd ("h", Left(ComboBox.Text,1), Now)

2007-01-11 18:28:51 · answer #3 · answered by MinstrelInTheGallery 4 · 2 0

fedest.com, questions and answers