物件安排與命名
TextBox元件 *3, Label元件 *3
txtResult 屬性Multiline 設定成True
Private Sub txtResult_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtResult.Click
Dim s1 As String
Dim intAge As Integer
Dim strName As String
intAge = Val(txtAge.Text)
strName = txtName.Text
s1 = strName + " 您的未來如下:" + vbNewLine +
"您將在 " & (intAge + Int(Rnd() * 11)) & " 歲結婚" + vbNewLine +
"您將會有 " & Int(Rnd() * 3) & " 個兒子" + vbNewLine +
"您將會有 " & Int(Rnd() * 3) & " 個女兒" + vbNewLine +
"您將活到 " & (60 + Int(Rnd() * 41)) & " 歲" + vbNewLine +
"您會有 " & Int(Rnd() * 4) & " 位情人"
txtResult.Text = s1
End Sub