Public Class Form1
Private Sub IntegerTest_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If Int(TextBox1.Text) > UShort.MaxValue Then
MsgBox("數字會不會太大了?? X<", 48, "Error")
Return
End If
Dim fact As UShort = CUShort(TextBox1.Text)
Dim ans As New List(Of ULong) From {1}
Label1.Text = "運算中..."
Me.Cursor = Cursors.WaitCursor
Application.DoEvents() 'Display
Dim nw As Date = Now
'Start Calculating
For i As UShort = 2 To fact
For j As Long = ans.Count - 1 To 0 Step -1
Dim nwans As ULong = ans(j) * i
If nwans > 99999999999999 Then
If j < ans.Count - 1 Then
ans(j + 1) += (Int(nwans / 100000000000000))
Else
ans.Add(Int(nwans / 100000000000000))
End If
ans(j) = Strings.Right(nwans, 14)
Else
ans(j) = nwans
End If
Next
Next
Dim fnans As String = ""
For Each a As ULong In ans
fnans = a.ToString("00000000000000") & fnans
Next
TextBox2.Text = fnans
Label1.Text = "Time Used: " & (Now - nw).ToString()
Me.Cursor = Cursors.Default
End Sub
End Class
★Kit↘..