2009年2月27日 星期五

九九乘法表(課本例題)

image

 

image

 

Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim mx(9, 9) As Integer
        Dim loop_I, loop_j As Integer
        Dim outstr As String
        For loop_I = 1 To 9
            For loop_j = 1 To 9
                mx(loop_I, loop_j) = loop_I * loop_j
            Next
        Next
        For loop_I = 9 To 1 Step -1
            For loop_j = 9 To 1 Step -1
                outstr = Format(loop_I, "0#")
                outstr = outstr & "*"
                outstr = outstr & Format(loop_j, "0#")
                outstr = outstr & "="
                outstr = outstr & Format(mx(loop_I, loop_j), "0#")
                TextBox1.Text = TextBox1.Text & "   " & outstr
            Next
            TextBox1.Text = TextBox1.Text & vbNewLine
        Next
    End Sub
End Class

 

[VB 2005 6-9頁例題]

沒有留言:

張貼留言