正在加载图片...
En Print x:" n;"次方="; Format(y,"##,##,#") Function Power(x As Single, n As Integer)As Double End if End Function 5.在窗体上设置三个窗体Form1~Form3.Form1中建立了两个文本框 TextI(“用户名”)和Text2(“密 码”),以及命令按钮 Commandl(“判断”)。Form2中建立了一个文本框 TextI(其Text属性值为“欢迎你 使用本系统”)和命令按钮 Commandl(“返回”)。Form3中建立了一个文本框Text1(其Text属性值为“对 不起,请向管理员查询”)和命令按钮 Command1(“退出”) Dim n As Integer Private Sub Commandl Click o 窗体 Forml的“判断” usern Trim(Textl. Text): passw Trim(Text2 Text) If usern =username And passw =password Then Form2 Show Else n=n+l: Text set Focus 3 Then Form3. Show Textl. Text = Text2 Text End sub Private Sub Form Activate Text. Tex TextI SetFocus End sub Private sub Commandl_ Click0‘窗体Form2的“返回 Form2 Hide End sub Private Sub Commandl Click O 窗体Form3的“退出” Unload Form2 Unload Form3 6.(1) Forml窗体模块程序代码 Private Sub Form Loado Randomize End sub Private Sub Commandl Click o 生成随机数 I To 10 a(i)= Int(ll+90 *k Rnd) s =s+ Str(a(i))+ Next i Textl, Text Left(s, Len(s)-1) End sub Private Sub Command2 Click O 求最大数 Text2 Text Max O End sub Private Sub Command3 Click O 打开排序窗口 Forml hide 隐藏主窗体 Form2 Show 显示“排序”窗体 1111 Print x; "的"; n; "次方="; Format(y, "###,###.##") End Sub Function Power(x As Single, n As Integer) As Double If n > 1 Then Power = Power(x, n - 1) * x Else Power = x End If End Function 5.在窗体上设置三个窗体 Form1~Form3。Form1 中建立了两个文本框 Text1(“用户名”)和 Text2(“密 码”),以及命令按钮 Command1(“判断”)。Form2 中建立了一个文本框 Text1(其 Text 属性值为“欢迎你 使用本系统”)和命令按钮 Command1(“返回”)。Form3 中建立了一个文本框 Text1(其 Text 属性值为“对 不起,请向管理员查询”)和命令按钮 Command1(“退出”)。 Dim n As Integer Private Sub Command1_Click() ‘窗体 Form1 的“判断” usern = Trim(Text1.Text):passw = Trim(Text2.Text) If usern = "username" And passw = "password" Then Form1.Hide Form2.Show Else n = n + 1:Text1.SetFocus If n = 3 Then Form1.Hide Form3.Show End If End If Text1.Text = "":Text2.Text = "" End Sub Private Sub Form_Activate() Text1.Text = "":Text2.Text = "" Text1.SetFocus End Sub Private Sub Command1_Click() ‘窗体 Form2 的“返回” Form2.Hide Form1.Show End Sub Private Sub Command1_Click() ‘窗体 Form3 的“退出” Unload Form1 Unload Form2 Unload Form3 End End Sub 6. (1) Form1 窗体模块程序代码: Private Sub Form_Load() Randomize End Sub Private Sub Command1_Click() '"生成随机数" Dim s As String s = "" For i = 1 To 10 a(i) = Int(11 + 90 * Rnd) s = s + Str(a(i)) + "," Next i Text1.Text = Left(s, Len(s) - 1) End Sub Private Sub Command2_Click() '"求最大数" Text2.Text = Max() End Sub Private Sub Command3_Click() '"打开排序窗口" Form1.Hide '隐藏主窗体 Form2.Show '显示“排序”窗体
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有