asp:Button action to change the asp:Label and generate random number (VB.net)
<%@ Page Language="VB" %>
<script runat="server">
Sub Button1_Click(sender As Object, e As EventArgs)
Label3.Visible = False
Label1.Text = Int(Rnd() * 6) + 1
Label2.Text = Int(Rnd() * 6) + 1
If Label1.Text = "1" And Label2.Text = "1" Then
Label5.Text = Label4.Text
If CInt(Label5.Text) > CInt(Label6.Text) Then
Label6.Text = label5.Text
End If
Label4.Text = 0
Label3.Visible = True
Else
Label4.Text = CInt(Label4.Text) + _
CInt(Label1.Text) + CInt(Label2.Text)
End If
End Sub
Sub Button2_Click(sender As Object, e As EventArgs)
Label6.Text = 0
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<h1>Snake Eyes!
</h1>
<p>
Keep going, but don't get two 1's...
</p>
<p>
<asp:Label id="Label1" runat="server" BorderStyle="Solid" Font-Names="Verdana" Font-Size="X-Large" Height="44px">0</asp:Label>
<asp:Label id="Label2" runat="server" BorderStyle="Solid" Font-Names="Verdana" Font-Size="X-Large" Height="44px">0</asp:Label>
</p>
<p>
<asp:Label id="Label3" runat="server" Visible="False">Ooops, you did it again :(</asp:Label>
</p>
<p>
<asp:Button id="Button1" onclick="Button1_Click" runat="server" Text="Hit me baby one more time..."></asp:Button>
</p>
<p>
<asp:Label id="Label4" runat="server" Font-Names="Verdana" Font-Size="X-Large" ForeColor="Red">0</asp:Label>
</p>
<p>
Last Score:<asp:Label id="Label5" runat="server" Font-Names="Verdana" Font-Size="X-Large" ForeColor="Red">0</asp:Label>
</p>
<p>
High Score:
<asp:Label id="Label6" runat="server" Font-Names="Verdana" Font-Size="X-Large" ForeColor="Red">0</asp:Label>
</p>
<p>
<asp:Button id="Button2" onclick="Button2_Click" runat="server" Text="Reset High Scores"></asp:Button>
</p>
</form>
</body>
</html>
Related examples in the same category