Jeg har fundet et sted på nettet, hvor jeg kan downloade VB-kode. Se her
nedenfor.
Men hvordan eksekverer jeg denne kode? Skal jeg lagre den med endelsen .frm
og åbne den i Visual Basic?
Eller skal jeg forsøge at kompilere den (lave den til en exe-fil) gennem
Visual Basic?
Jeg er helt begynder, så undskyld hvis jeg spørger dumt.
v.h.
Jakob Munck
--------------------------------------------------------
Eks på kode:
**************************************
' Name: A little clock that sits on your
' desktop
' Description:This gives the code for a
' little arlarm clock that sits on your de
' sktop. The soul purpose of this applicat
' ion is to give the current time. Very Si
' mple.
' By: Mike-Ejeet 9t9
'
'
' Inputs:1 timer- Interval 500 and name
' timer 1
'
' Returns:None
'
'Assumes:None
'
'Side Effects:None
'This code is copyrighted and has limite
' d warranties.
'Please see
http://www.Planet-Source-Cod
' e.com/xq/ASP/txtCodeId.4961/lngWId.1/qx/
' vb/scripts/ShowCode.htm
'for details.
'**************************************
I(n the form itself enter this code:
Private Sub Form_Click()
AlarmTime = InputBox("Enter alarm time", "VB Alarm", AlarmTime)
If AlarmTime = "" Then Exit Sub
If Not IsDate(AlarmTime) Then
MsgBox "The time you entered was not valid."
Else' String returned from InputBox is a valid time,
AlarmTime = CDate(AlarmTime)' so store it as a date/time value in
AlarmTime.
End If
End Sub
**********In the timer enter this code:*****************
Private Sub Timer1_Timer()
Static AlarmSounded As Integer
If lblTime.Caption <> CStr(Time) Then
' It's now a different second than the o
' ne displayed.
If Time >= AlarmTime And Not AlarmSounded Then
Beep
MsgBox "Alarm at " & Time
AlarmSounded = True
ElseIf Time < AlarmTime Then
AlarmSounded = False
End If
If WindowState = conMinimized Then
' If minimized, then update the form's C
' aption every minute.
If Minute(CDate(Caption)) <> Minute(Time) Then SetCaptionTime
Else
' Otherwise, update the label Caption in
' the form every second.
lblTime.Caption = Time
End If
End If
End Sub