Function HitRate(ByVal Hits As Short, ByVal Tries As Short) As String
Dim percent As Single
percent = Hits / Tries
Return Format(percent, "0.0%")
End Function
This isn't the first function that I have written although I am not entirely sure on what it is or what it is for.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.Visible = False
Randomize()
Label1.Text = CStr(Int(Rnd() * 10))
Label2.Text = CStr(Int(Rnd() * 10))
Label3.Text = CStr(Int(Rnd() * 10))
Spins = Spins + 1
If (Label1.Text = "7") Or (Label2.Text = "7") _
Or (Label3.Text = "7") Then
PictureBox1.Visible = True
Beep()
Wins = Wins + 1
lblWins.Text = "Wins: " & Wins
End If
lblRate.Text = HitRate(Wins, spins)
End Sub
I added subs to my radiation computer game
Sub emergencyVentAction()
pressure += -30
power += -20
score += 10
End Sub
Sub bathAction()
pressure += 5
radiation += -25
power += -20
score += 10
End Sub
Finally I am including here my own program using a function
Public Class Form1
Public number As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Randomize()
End Sub
Function randomizer() As Integer
Dim rndNumber As Random
rndNumber = New Random
number = rndNumber.Next(1, 1001)
Return number
End Function
Private Sub btnRandomize_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRandomize.Click
Dim numberOne As Integer
numberOne = randomizer()
MsgBox(numberOne)
End Sub
End Class
No comments:
Post a Comment