473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Label appears after 10 seconds

Hi,

I have been searching the internet and this forum for the answer to my problem, but so far nothing is working. I want a label to appear 10 seconds after the form loads. This is one of the codes that I have tried so far


Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.         Timer1.Interval = 60000
  3.         Timer2.Interval = 10000
  4.  
  5.  End Sub
  6.  
  7. Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  8.         Static Flag As Integer
  9.         Flag = Flag + 1
  10.         If Flag = 1 Then
  11.             Label2.Visible = False
  12.         Else
  13.             Label2.Visible = True
  14.         End If
  15.         Flag = 0
  16. End Sub
  17.  
but it doesn't work. Like this the label is visible when the form loads and then disappears, but if I switch the Label2.Visible = True & False the code doesn't work at all. It also doesn't do anything if I change the = to a less than sign. Any and all help is appreciated. Thanks!
Nov 1 '11 #1
3 6953
Asprisa
30
Hi,

I assume you have timer2.start() in the form_load?

Also in the tick event, flag has not been set to anything, i would first assign Flag a value like 0, but then your code says flag = flag + 1 so the value would be 1, meaning the value of the label would be set to visible = false, and at the end of the event Flag is set back to 0, meaning the value would only ever be 1 or visible = false.

I do not know what the Flag does, but maybe you try
Expand|Select|Wrap|Line Numbers
  1. Static Flag As Integer
  2. Flag = Flag + 1
  3. If Flag = 1 Then
  4.     Label2.Visible = False
  5. Elseif Flag = 0 OR Flag > 1
  6.     Label2.Visible = True
  7. End If
  8. Flag = 0
  9.  

Let me know if this helps.

James.
Nov 10 '11 #2
Thanks for your help, but I actually already got it to work with the code below.
Expand|Select|Wrap|Line Numbers
  1. Private Sub AnagramExample_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.     Word.Visible = False
  3.     Timer2.Interval = 10000
  4.     Timer2.Enabled = True
  5. End Sub
  6.  
  7. Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  8.     Word.Visible = True
  9.     Timer2.Enabled = False
  10. End Sub
Nov 10 '11 #3
thanx friend it was rally good info.
Oct 31 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Jared | last post by:
Here is my situation. I have multiple labels on a form but only certain ones will become visible while using the form. Depending on which check box(s) you pick, on another form, determines the...
0
by: Adonai | last post by:
Hi, I'm having an issue with this code that I'm writing, I'm curious as to why the windows form label (lblTime) isn't getting updated with the new variable when I use the timer. I made a blank form...
5
by: AlexGray | last post by:
Hi, I created a blank Form with one Label, and the Label's text says "Loading... Please wait.". I display this form in Main() with Show() while i do some lengthy initialization stuff (ie...
3
by: mike | last post by:
Hi People, I have an aspx file, extremely simple, it only contains a label and a button. When I view the page in IE, only the label is visible, not the button. Its being served by IIS5 on...
1
by: nospamjac | last post by:
Hi, Is there a way to update the text of an asp:label on a webform without refreshing the entire page? What is called by button clicks and other events that refresh a webform control? See the...
2
by: What-a-Tool | last post by:
Decided to try and do it this way just to see if I could. My form appears with a rectangular hole in the center the size of my label. can anyone tell me why, and if it can be made visible? ...
4
by: darnnews | last post by:
When a user selects a "Medium" in a form I have made, I would like to change a Label on the form. Can I change a label based on an update of a listbox? This code does not work: Case "Print"...
3
by: Cas | last post by:
Hi, I want to display a label a few seconds, then make it invisible. I tried with for next, but it doesn't work. Thanks for help Cas
3
by: KenMacksey | last post by:
Hi I am running VB6 on a pentium 4 and Win XP pro. I wrote a small program to copy files to a memory card or mp3 player etc in a specific order or a random order instead of the windows default...
9
by: =?Utf-8?B?RnJhbmsgVXJheQ==?= | last post by:
Hi all I have a MDI Container Form, with one label control on the Background of this container form. When I now open a child form, this form is behind the label ... and this looks ugly ... :-))...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.