Visu al Basic ---课程设计与心得 班级:计科 107 姓名:张麟树 学号:1004681324 一、实验课题:设计一个能计算 2 阶、3 阶、4 阶行列式的小软件,运行时先由用户输入行列式的阶数,然后软件自动生成行列式的输入模板,如用户输入的阶数是 3 ,则产生 9 个输入框并排成 3 行 3 列且用两条竖线界定。这里需用控件的动太加载技术。 二、实验代码: Dim N As Integer Pu blic Fu nction choose(By Val X As Integer) Do If X = 2 Then With Form1 .Line1.Visible = Tru e .Line2.Visible = Tru e .Line3.Visible = False .Line4.Visible = False .Line5.Visible = False .Line6.Visible = False End With For I = 0 To 3 Form1.Tex t1(I).Visible = Tru e Nex t I Ex it Do ElseIf X = 3 Then With Form1 .Line1.Visible = False .Line2.Visible = False .Line5.Visible = False .Line6.Visible = False .Line3.Visible = Tru e .Line4.Visible = Tru e End With For I = 0 To 8 Form1.Tex t1(I).Visible = Tru e Nex t I Ex it Do ElseIf X = 4 Then With Form1 .Line3.Visible = False .Line4.Visible = False .Line1.Visible = False .Line2.Visible = False .Line5.Visible = Tru e .Line6.Visible = Tru e End With For I = 0 To 15 Form1.Tex t1(I).Visible = Tru e Nex t I Ex it Do Else Call Command1_Click End If Loop End Fu nction Pu blic Fu nction Hu any u an() Dim I As Integer For I = 0 To 15 Form1.Tex t1(I).Visible = False Nex t I With Form1 .Line1.Visible = False .Line2.Visible = False .Line3.Visible = False .Line4.Visible = False .Line5.Visible = False .Line6.Visible = False End With End Fu nction Priv ate Su b Command1_Click() Dim I As Integer Call Hu any u an N = Inpu tBox ("请输入阶数(2、3 或 4):") For I = 0 To 15 Form1.Tex t1(I).Tex t = "" Nex t I Call choose(N) End Su b Priv ate Su b Command2_Click() Dim v al As Integer If N = 2 Then v al = Form1.Tex t1(0)...