Help with Loops

+1 Johnny Travis · November 17, 2015
Trying to figure out how to get the power of a number from two text boxes into a label, im having trouble figuring out wehre to start.

Post a Reply

Replies

Oldest  Newest  Rating
0 David Lim · November 22, 2015
Hi,

Have you figure out? Are you using VBA? 

Not really sure if this will help you, as I don't really understand the question.
Assuming you created a UserForm, this will be the code if it were to be run by VBA.


Private Sub CommandButton1_Click()

Dim x As Integer 'Using x as a counter variable (Loop Method)
Dim y As Integer 'The variable result for each loop

    x = 1
    
    Do Until x = TextBox2.Value
        
        If x 1 Then
        
            y = y * TextBox1.Value
        
        Else
        
        y = TextBox1.Value * TextBox1.Value
        
        End If
        
        x = x + 1
        
    Loop
    
    Label1.Caption = y

End Sub
  • 1

Visual Basic

107,122 followers
About

One of the first products to provide a graphical environment and a paint metaphor for developing user interfaces.

Links
Moderators
Bucky Roberts Administrator