Library code snippets
Exponentiation
Introduction
Intoduction: Exponentiation
Stupidity can sometimes be good... I'm talking about this code, i was so dumm that i made this math function cause i though that there isn't one in the VB library, it's simple, i dunno if you can benefit from it, but i know that you can take this code as an example to learn how to create your own stuff even the simplest of them all.
Private Sub Command1_Click()
Text3.Text = exp(Text1.Text, Text2.Text)
End Sub
Public Function exp(ByVal number As Single, ByVal exponent As Long) As Single
Dim z As Integer
Dim numb As Single
numb = 1
For z = 1 To exponent
If exponent = 1 Then
numb = number
exp = numb
Exit For
Exit Function
ElseIf exponent = 0 Then
Exit For
numb = 1
exp = numb
Exit Function
ElseIf z >= 1 And z <= exponent Then
numb = number * numb
exp = numb
End If
Next z
End Function
Or you can use: ^ instead :)
Comments
Leave a comment
Sign in or Join us (it's free).