Hi Frank,
You only need 1 label. Using my sample form, change my code to (tested) that
below. You may want to shorten strLen to 30 because there's fewer characters
in your string.
Private Sub Form_Timer()
Static strMsg As String
Static intLet As Integer
Static intLen As Integer
Dim strTmp As String
Dim strGreeting As String
Dim t As Double
Const strLen = 40
t = Time()
Select Case t
Case Is < 0.5
strGreeting = "Selamat Pagi"
Case 0.5 To 0.75
strGreeting = "Selamat Siang"
Case Is > 0.75
strGreeting = "Selamat Malam"
Case Else
MsgBox "Fix your computer's clock"
Exit Sub
End Select
If Len(strMsg) = 0 Then
strMsg = Space(strLen) & strGreeting
intLen = Len(strMsg)
End If
intLet = intLet + 1
If intLet > intLen Then
intLet = 1
End If
strTmp = Mid(strMsg, intLet, strLen)
Me!lblScroll.Caption = strTmp
If strTmp = Space(strLen) Then
intLet = 1 'Re-start scrolling
End If
End Sub
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
The problem Arvin, coz I have 3 conditional wecoming word, and I tried
them
this way but does not work.
Private Sub Form_Timer()
'When the database is opened display welcome user message.
Dim strMsg As String
Static I As Integer
If Time() < 0.5 Then
[lblMorning].Visible = True
[lblAfternoon].Visible = False
[LblEvening].Visible = False
I = I + 1
strMsg = "Selamat Pagi"
If I > Len(strMsg) Then I = 1
lblMorning.Caption = lblMorning.Caption & Mid(strMsg, I, 1)
End If
ElseIf Time() > 0.5 And Time() < 0.75 Then
[lblMorning].Visible = False
[lblAfternoon].Visible = True
[LblEvening].Visible = False
I = I + 1
strMsg = "Selamat Siang"
If I > Len(strMsg) Then I = 1
lblAfternoon.Caption = lblAfternoon.Caption & Mid(strMsg, I, 1)
End If
ElseIf Time() > 0.75 Then
[lblMorning].Visible = False
[lblAfternoon].Visible = False
[LblEvening].Visible = True
I = I + 1
strMsg = "Selamat Malam"
If I > Len(strMsg) Then I = 1
LblEvening.Caption = LblEvening.Caption & Mid(strMsg, I, 1)
End If
End If
End Sub
--
H. Frank Situmorang
:
You might want to try the working code in this sample database:
http://www.datastrat.com/Download/Scroll.zip
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
Hello,
Can any body help me how to make this 3 conditional welcoming words can
work
true. This is VBA I learned from Database Dev UK.ID :
Private Sub Form_Timer()
Dim strMsg As String
Static I As Integer
I = I + 1
strMsg = "Selamat Pagi "
If I > Len(strMsg) Then I = 1
lblMorning.Caption = lblMorning.Caption & Mid(strMsg,
I,
1)
End Sub
While this is the VBA to make a scrolling words:
Private Sub Form_Timer()
Dim strMsg As String
Static I As Integer
I = I + 1
strMsg = "Some message here "
If I > Len(strMsg) Then I = 1
LabelName.Caption = LabelName.Caption & Mid(strMsg, I, 1)
End Sub
MY QUESTION IS HOW CAN WE COMBINE THESE 2 VBA TO MAKE IT WORKS IN THE
ABOVE
3 CONDITIONAL WORDS.
Thanks in advance,