Home > Software engineering >  Use Timer control dynamically generated random number problem! Online, wait ~ ~ ~ ~ ~
Use Timer control dynamically generated random number problem! Online, wait ~ ~ ~ ~ ~

Time:09-24

Use the Timer control dynamically generated random number in the VB.net, click Button2 stop the Timer control, three Label will have to jump in the software interface code, very confused, for this, I found a screenshot of the online application in every time to stop the Timer control, capture screen figure, comparison, discovered after screenshots, three Label control with the value of the software show the value of the three Label sometimes inconsistent, sometimes consistent with the phenomenon, excuse me each expert, this is how to return a responsibility?
The attached code:
 Public Class Form1 

Private Sub CatchLDDRezult ()
Dim p1 As New Point (0, 0)
Dim p2 As New Point (Screen. PrimaryScreen. Bounds. Width, Screen, PrimaryScreen. Bounds. Height)
Dim PIC As New Bitmap (p2) X, p2. Y)
Using g As Graphics=Graphics. FromImage (PIC)
Right opyFromScreen (p1, p1, p2)
PIC. Save (" D: \ 1. JPG ")
End Using
End Sub

Private Sub Form1_Load (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles MyBase. Load

End Sub

Private Sub Button1_Click (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles for. Click
Timer1. Enabled=True
End Sub

Private Sub Button2_Click (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles Button2. Click
Timer1. Enabled=False
CatchLDDRezult ()
End Sub

Private Sub Timer1_Tick (ByVal sender As System. Object, ByVal e the As System. EventArgs) Handles Timer1. Tick
Randomize ()
Dim intRndLDid As Integer=Int (Rnd () * 941 + 1)
Dim strRndLDid As String=Format (intRndLDid, "0000")
Label1. Text=strRndLDid

Randomize ()
IntRndLDid=Int (Rnd () * 941 + 1)
StrRndLDid=Format (intRndLDid, "0000")
Label2. Text=strRndLDid

Randomize ()
IntRndLDid=Int (Rnd () * 941 + 1)
StrRndLDid=Format (intRndLDid, "0000")
Label3. Text=strRndLDid

Label4. Text=Now
End Sub
The End of the Class


CodePudding user response:

Software after the operation interface and screen interface after contrast

Inconsistent


Consistent

CodePudding user response:

If your Timer1 "cycle" setting is too small, less than 18 ms?
  •  Tags:  
  • API
  • Related