[RESOLVED] Help on how to update or refresh text in my animated label text
hi i need some help again... i have 2 forms, first form is the "insert announcement", 2nd form is my "main form" in my main form you can find a LABEL "LBLANNOUNCEMENT" here is the situation, one you add a announcement in 1st form then click add announcement in the 2nd form it will show in the lblannouncement, it working but my problem is updating it, i add menu editor and put announcement there, so once you click announcement in the menu the form 1 will again appear but when you click the send announcement button, the text in the lblannouncement is not changing.. here is my code:
Form 1 is frmannounce
Form 2 is frmnumber
in my menu editor i added Announcement it is located at the frmnnumber
Code:
Private Sub Announce_Click()
frmannounce.Show
End Sub
Code:
'it is located the frmannoune
Private Sub cmdsend_Click()
'to send the announcement to form2
Text1.Text = frmnumber.lblannounce.Caption
frmnumber.Show
Unload Me
End Sub
'it is located at the frmnumber
Private Sub Form_Load()
lblannounce.Caption = "Default Message" & frmannounce.Text1.Text
End Sub
Re: Help on how to update or refresh text in my animated label text
what about
vb Code:
lblannounce.Caption = ""
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
Re: Help on how to update or refresh text in my animated label text
You might find it easier if you had a public String variable located in a BAS module. In cmdsend_Click, you assign the announcement to the String variable and then you show frmnumber. When frmnumber loads, it sets the Caption of lblannounce to the public String variable.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Re: Help on how to update or refresh text in my animated label text
If frmNumber is already loaded then when you execute 'frmNumber.Show' the _Load event is not triggered so your code will not be executed. It'll work on the first time (i.e. when frmNumber is first Loaded) but not on subsequent ones (i.e. when it is Shown). You'd be better off moving the code from the _Load event to the _Activate event.
Last edited by Doogle; May 16th, 2013 at 02:26 AM.
Re: Help on how to update or refresh text in my animated label text
Originally Posted by Doogle
You'd be better off moving the code from the _Load event to the _Activate event.
Wouldn't frmnumber's Activate event be triggered every time focus moves from frmannounce to it?
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Re: Help on how to update or refresh text in my animated label text
Yes it cetainly would - not sure whether it matters in this 'simple' case. I suppose another option would be to keep the code in the _Load event and Unload frmNumber before Showing it.
Re: Help on how to update or refresh text in my animated label text
Originally Posted by Doogle
If frmNumber is already loaded then when you execute 'frmNumber.Show' the _Load event is not triggered so your code will not be executed. It'll work on the first time (i.e. when frmNumber is first Loaded) but not on subsequent ones (i.e. when it is Shown). You'd be better off moving the code from the _Load event to the _Activate event.
yes thats my problem once the main form is already open the load event is not trigger.... im thinking if it can be refresh like adding in the
Code:
Private Sub cmdsend_Click()
'to send the announcement to form2
Text1.Text = frmnumber.lblannounce.Caption
frmnumber.Show
frmnumber.lblannounce.Refresh
Unload Me
End Sub
i tried it but its not still working... if im going to remove it in the form_load() ill put the code in the lblannouncement directly? sorry im not yet good at vb6 just starting to learn and its my first project...
by the way the startup object is the frmannounce....
Re: Help on how to update or refresh text in my animated label text
@Doogle,
I was just about to suggest the same thing!
@phatus,
try
vb Code:
'put in frmNumber
Private Sub Form_Activate()
frmnumber.lblannounce.Refresh
End Sub
Put the above code in frmNumber.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu. https://get.cryptobrowser.site/30/4111672
Re: Help on how to update or refresh text in my animated label text
here is my complete code in frmannounce and frmnumber
frmannounce
Code:
Private Sub cmdsend_Click()
Text1.Text = frmnumber.lblannounce.Caption
frmnumber.Show
Unload Me
End Sub
frmnumber
Code:
Option Explicit
Private spk As SpVoice
Private Declare Function Beep Lib "kernel32" _
(ByVal dwFreq As Long, ByVal dwDuration As Long) As Long
Private Sub Abouts_Click()
frmAbout.Show
End Sub
Private Sub Announce_Click()
frmannounce.Show
End Sub
Private Sub Exit_Click()
Dim response As String
response = MsgBox("Are You Sure You Want To Close The Program", vbYesNo, "Exit")
If response = vbYes Then
End
Else
Me.Show
End If
End Sub
Private Sub SpeakIt(strWords As String)
If strWords <> vbNullString Then
spk.Speak strWords
End If
End Sub
Private Sub Form_Load()
lblannounce.Caption = "You can check the status of your document online with your tracking number Icon... " & frmannounce.Text1.Text & "... "
Timer1.Enabled = True
Timer1.Interval = 300
Set spk = New SpVoice
Dim cx As Long
Dim cy As Long
Dim RetVal As Long
lbldate.Caption = Format(Now, "mmmm dd,yyyy")
Timer1.Interval = 200
'playing sound
Dim app_path As String
app_path = App.Path
If Right$(app_path, 1) <> "\" Then
app_path = app_path & "\"
txtmusic.Text = app_path & "BuddyIsOnline.wav"
End If
With mmcplayer
.Notify = False
.Wait = True
.Shareable = False
.Command = "close"
End With
End Sub
Private Sub mmcplayer_done(notifycode As Integer)
mmcplayer.Command = "close"
lblaudio.Caption = ""
End Sub
Private Sub mmcplayer_statusupdate()
lblaudio.Caption = mmcplayer.Position & "/" & mmcplayer.Length
End Sub
Private Sub lblreceive_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
lblreceive.Caption = Val(lblreceive.Caption) + 1
SpeakIt "Now Serving Number" & lblreceive.Caption & "at receiving window"
With mmcplayer
If lblreceive.Caption = lblreceive.Caption <= 30 Then
.FileName = txtmusic.Text
.Command = "open"
.Command = "play"
Else
.Command = "stop"
.Command = "close"
End If
End With
End If
If lblreceive.Caption = 31 Then
lblreceive.Caption = "0"
End If
If Button = 2 Then
lblreceive.Caption = Val(lblreceive.Caption) - 1
End If
Dim response As String
If lblreceive.Caption < 0 Then
response = MsgBox("Reset to 0", vbExclamation, "ERROR")
lblreceive.Caption = Val(lblreceive.Caption) + 1
End If
End Sub
Private Sub lblrelease_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 1 Then
lblrelease.Caption = Val(lblrelease.Caption) + 1
SpeakIt "Now Serving Number" & lblrelease.Caption & "at releasing window"
With mmcplayer
If lblrelease.Caption = lblrelease.Caption <= 30 Then
.FileName = txtmusic.Text
.Command = "open"
.Command = "play"
Else
.Command = "stop"
.Command = "close"
End If
End With
End If
If Button = 2 Then
lblrelease.Caption = Val(lblrelease.Caption) - 1
End If
If lblrelease.Caption = 31 Then
lblrelease.Caption = "0"
End If
If lblrelease.Caption < 0 Then
Dim response As String
response = MsgBox("Reset to 0", vbExclamation, "ERROR")
lblrelease.Caption = "0"
End If
End Sub
Private Sub Timer1_Timer()
lblhr.Caption = Format$(Now, "hh:mm:ss AM/PM")
Dim str As String
str = frmnumber.lblannounce.Caption
str = Mid$(str, 2, Len(str)) + Left(str, 1)
frmnumber.lblannounce.Caption = str
End Sub
my only problem is when updating the announcement when the frmnumber is loaded it wont update so inneed to exit the program first then update the announcement...
Re: Help on how to update or refresh text in my animated label text
You need to make frmnumber's lblannounce.Caption independent from the Form Load event. One way would be to set the label's Caption in frnannounce.
frmannounce:
Code:
Private Sub cmdsend_Click()
frmnumber.lblannounce.Caption = "You can check the status of your document online with your tracking number Icon... " & Text1.Text & "... "
frmnumber.Show
Unload Me
End Sub
and remove
Code:
lblannounce.Caption = "You can check the status of your document online with your tracking number Icon... " & frmannounce.Text1.Text & "... "
Re: Help on how to update or refresh text in my animated label text
Originally Posted by Doogle
You need to make frmnumber's lblannounce.Caption independent from the Form Load event. One way would be to set the label's Caption in frnannounce.
frmannounce:
Code:
Private Sub cmdsend_Click()
frmnumber.lblannounce.Caption = "You can check the status of your document online with your tracking number Icon... " & Text1.Text & "... "
frmnumber.Show
Unload Me
End Sub
and remove
Code:
lblannounce.Caption = "You can check the status of your document online with your tracking number Icon... " & frmannounce.Text1.Text & "... "
from frnnumber's Load event
theres a problem on that when you click the File>Announcement in the menu and the frmannounce will appear and when you put another announcement for update
i attached my project so that you can see what i mean....
Last edited by phatus; May 16th, 2013 at 04:36 AM.
Reason: deleted attached file
Re: Help on how to update or refresh text in my animated label text
I changed frmannounce to
Code:
Private Sub cmdsend_Click()
frmnumber.lblannounce.Caption = " You can check the status of your document online with your tracking number @ www.depedcamsur.com and look for DOTs Icon... " & Text1.Text & "... "
frmnumber.Show
Unload Me
End Sub