|
楼主 |
发表于 2010-3-5 23:40:53
|
显示全部楼层
附上源代码【VB.NET 2008】- Imports System.Math
- Public Class Form1
- Private Sub form1_closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
- Timer2.Enabled = True
- e.Cancel = True
- End Sub
- Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
- Me.Opacity = 0
- Timer1.Enabled = True
- End Sub
- Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
- Me.Opacity += 1 / 50
- If Me.Opacity = 1 Then Timer1.Enabled = False
- End Sub
- Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
- Me.Opacity -= 1 / 50
- If Me.Opacity = 0 Then End
- End Sub
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Dim result As Long, n As Integer = 0, send As Long
- Dim 数字类型 As String
- Try
- result = Convert.ToInt32(TextBox1.Text)
- Catch
- End Try
- If result <> 0 Then
- TextBox2.Text = "开始验证" & vbCrLf & "初始数据 = " & result
- If result <> 1 Then
- Do While result <> 1
- send = result
- If result Mod 2 = 1 Then
- result = result * 3 + 1
- 数字类型 = "奇数"
- Else
- result = result / 2
- 数字类型 = "偶数"
- End If
- n += 1
- TextBox2.Text += vbCrLf & "进行第 " & Convert.ToString(n) & " 次运算" & vbCrLf & "数字" & Convert.ToString(send) & "为" & 数字类型 & vbCrLf & "进行运算:"
- If 数字类型 = "奇数" Then
- TextBox2.Text += Convert.ToString(send) & " * 3 + 1 = " & Convert.ToString(result)
- Else
- TextBox2.Text += Convert.ToString(send) & " / 2 = " & Convert.ToString(result)
- End If
- Loop
- Else
- TextBox2.Text += "result = 1"
- End If
- TextBox2.Text += vbCrLf + "验证完毕!"
- Else
- MsgBox("输入数据有误!", 128, "错误")
- End If
- End Sub
- Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
- TextBox1.Text = ""
- TextBox1.ForeColor = Color.Black
- End Sub
- End Class
复制代码 |
|