To display in a label
-
I have used the following code to display # in a label.But it is getting displayed only once.Why? Private Sub Command1_Click() Dim n, i As Integer n = Val(Text1.Text) Label2.Caption = "" For i = 1 To n Label2.Caption = "#" Next End Sub
-
I have used the following code to display # in a label.But it is getting displayed only once.Why? Private Sub Command1_Click() Dim n, i As Integer n = Val(Text1.Text) Label2.Caption = "" For i = 1 To n Label2.Caption = "#" Next End Sub
Softtips2004 wrote: I have used the following code to display # in a label.But it is getting displayed only once.Why? Private Sub Command1_Click() Dim n, i As Integer n = Val(Text1.Text) Label2.Caption = "" For i = 1 To n Label2.Caption = "#" Next End Sub Your only getting one '#' because your overwritting the value in Label2.Caption 'n' times, your not appending to it. If you want to append to it then you have to do something like this:
Label2.Caption = ""
For i = 1 To n
Label2.Caption = Label2.Caption & "#"
NextOr you could simplify it even further and do it this way:
Private Sub Command1_Click()
Dim n as Integer = Val(Text1.Text)
Label2.Caption = new String("#", n)
End SubRageInTheMachine9532
-
I have used the following code to display # in a label.But it is getting displayed only once.Why? Private Sub Command1_Click() Dim n, i As Integer n = Val(Text1.Text) Label2.Caption = "" For i = 1 To n Label2.Caption = "#" Next End Sub
:cool: hey it is so simple the code is given here Private Sub Command1_Click() Dim n, i As Integer n = Val(Text1.Text) Label2.Caption = "" For i = 1 To n Label2.Caption = Label2.Caption + "#" Next End Sub Any Problem Contact me :cool: VickyMD a Specialist in Message Digest Security i think so i m posting it 2 seconds late sorry for that
-
:cool: hey it is so simple the code is given here Private Sub Command1_Click() Dim n, i As Integer n = Val(Text1.Text) Label2.Caption = "" For i = 1 To n Label2.Caption = Label2.Caption + "#" Next End Sub Any Problem Contact me :cool: VickyMD a Specialist in Message Digest Security i think so i m posting it 2 seconds late sorry for that