Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27554

Working with Functions...

$
0
0
I had to write a program that would produce the amount of time it would take to get from one point to another based on warp speed etc etc and this is what I had:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim units, warpfactor, speed, time As Double
Dim output As String
If TextBox1.Text = "" Or TextBox2.Text = "" Then
MsgBox("You MUST enter units and warp factor to continue")
Exit Sub
End If
units = Val(TextBox1.Text)
warpfactor = Val(TextBox2.Text)
speed = warpfactor ^ (10 / 3)
time = (100 / speed) * units
TextBox3.Text = time

End Sub
End Class

and it looks like this: Name:  display.png
Views: 190
Size:  28.1 KB

but apparently I'm supposed to do "speed = warpfactor ^ (10 / 3)" and "time = (100 / speed) * units" as functions -- how would I write them that way but still produce the same result?
Attached Images
 

Viewing all articles
Browse latest Browse all 27554

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>