Home > Software engineering >  VB loop statements in the body results displayed how one by one?
VB loop statements in the body results displayed how one by one?

Time:11-11

There are such a cycle
For I=1 to 10
Text1. Text=I
Next I

How can ability let the text box shows that 1 in turn,2,3,4,5,6,7,8,9,10, that is the result of the loop body statements show come out?

CodePudding user response:

If I=1 then
Text1. Text=I
The else
Text1. Text=text1. Text & amp; ", "& amp; I
endif

CodePudding user response:

Don't quite understand what you want, if just let it automatically switches display number, you can try Dovents + Sleep (), according to a, have a rest, continue to show

CodePudding user response:

Yes, and I also checked the online, use DOVENTS + SLEEP () can say more, but I'm up and running, also not line, I write it like this:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click ()
For I=1 To 10
Text1. Text=I
Sleep 1000
Dovents
Next I
End Sub

But there will be a mistake, who can specifically how to write how much?

CodePudding user response:

Doevents first, then sleep

CodePudding user response:

Butt, doevents first, the data displayed, to sleep again

CodePudding user response:

Place a Command control, and a TextBox control
 
Dim flag As Boolean
Private Sub Command1_Click ()
For I=1 To 10
If Not flag=False Then Text1. Text=Text1. Text & amp; ", "& amp; I
If flag=False Then Text1. Text=Text1. Text & amp; I
If flag=False Then flag=True
Next
End Sub
Private Sub Form_Load ()
Flag=False
Text1. Text=""
End Sub
  • Related