Label Refresh problem


Hi Every one; I have a timer that executes my start button every 15 minutes then displays clients available credit in a label and if it is < 1000 then a mail gets sent out, which works fine. But now I want the labels to refresh every time the cmdstart button gets executed. I’ve played around a bit but and did search other posts but can’t seem to get it right, here’s what I’ve got a DoEvents can be use but I don’t know where to place it,

[CODE]
Private Sub cmdstart_Click()
If lblMsgD <= 1000 Then
Dim olmahApp As Outlook.Application
Set olmahApp = CreateObject("Outlook.Application")

Dim olmahNs As Outlook.Namespace
Set olmahNs = olmahApp.GetNamespace("MAPI")
olmahNs.Logon

Dim olmahMail As Outlook.MailItem
Set olmahMail = olmahApp.CreateItem(olmahMailItem)
olmahMail.To = "some@one.gov.za"
olmahMail.Subject = "VB TEST"
olmahMail.Body = _
"Good Day Magoveni Holdings" & ", " & vbCr & vbCr & vbTab & _
"Please note that your credit is all most finish ." & ", " & vbCr & vbCr & vbTab & _
"Many Thanks"
olmahMail.Send
olmahNs.Logoff
Set olmahNs = Nothing
Set olmahMail = Nothing
Set olmahApp = Nothing
End If
DoEvents
lblMsgA.Refresh
End Sub

Private Sub tmrMinute_Timer()
MinCount = MinCount + 1
Label1.Caption = MinCount
If (MinCount = 10) Then
Call cmdstart_Click
MinCount = 0
End If
lblMsgA.Refresh
End Sub
[/CODE]

If you enjoyed this post, subscribe for updates (it's free)

How to return the value of label box to 0?

Hi! I Made a vb6 scoreboard just for paractice, my project has 3 labels lblHome, lblVisitor and lblResult. lblHome and lblVisitor is where the scores display, it also has a restart button(cmdRestart). My problem is if I click the restart button it clears lblHome, lblVisitor and lblResult, but it doesn't return the value of lblHome and lblVisitor to 0. the result is after I click the restart button it clears the 3 label box but if I put the new score(say 2) the new score will add to the last score(say 10) and the score will become 12. I know something is lacking. Guys can you help me? By the way here's my code:

Private Sub cmdRestart_Click()
lblHome.Caption = ""
lblVisitor.Caption = ""
lblResult.Caption = ""

End Sub

Return values label

Of course it won't restore any values because you aren't telling it to. That code just clears the labels.

Where does it get these values form, database, file or from some where else?

Keith
www.martin2k.co.uk/forums/

I've been programming with VB for 13 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning

Label value to 0

The label boxes get their respective values just inside the form where they are located, I have 3 command buttons for each label box, a total of 6 command buttons thats for the 1 point, 2 points, and 3 points. If I click the 2 points button it will appear on the label box. Can you give me a code to clear and return the value of my label boxes(lblHome and lblVisitor)? Thanks!

Label Refresh

Well there is something in that code that doesn't look right.

You have a Timer control

Private Sub tmrMinute_Timer()
MinCount = MinCount + 1
Label1.Caption = MinCount
If (MinCount = 10) Then
Call cmdstart_Click
MinCount = 0
End If
lblMsgA.Refresh
End Sub

You haven't stated the Interval for that Timer but after 10 times through it you Call cmdstart_Click. Then in the Start button you have

If lblMsgD <= 1000 Then

So lblMsgD.Caption is part of this Timer result? Whats changing the lblMsgD.Caption?

A little VB tip when you are using control properties alway show the property you and to use. As regards a Label use the Caption property don't assume its that. A lot of users just use Text1 = 1000. That could be the text or it could be any other value for that control. I know Text is the default but your code will be a lot easier to follow.

If lblMsgD.Caption <= 1000 Then

You've used the Caption on Label1. But what is Label1 doing apart from counting 0 - 10?

Keith
www.martin2k.co.uk/forums/

I've been programming with VB for 13 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].

More information about formatting options

Type the characters you see in this picture. (verify using audio)
Type the characters you see in the picture above; if you can't read them, submit the form and a new image will be generated. Not case sensitive.