VB里用星号输出平行四边形、正三角、倒三角的程序语句?
一、Private Sub Form_Click()
show
Dim m, n, i, j As Integer
m = 4 :n = 7
For i = 1 To m
For j = 1 To m - i + 1
Print " ";
Next j
For j = 1 To n
Print "*";
Next j
Next i
For i = 1 To m
For j = 1 To m - i + 1
Print " ";
Next j
For j = 1 To 2 * i - 1
Print "*";
Next j
Next i
For i = 1 To m
For j = 1 To i
Print " ";
Next j
For j = 1 To 2 * m - 2 * i + 1
Print "*";
Next j
Next i
End Sub
二、Sub Command1_Click()
Dim i As Integer
For i = 1 To 11 Step 2
For m = 11 To i Step -1
Debug.Print "*";
Next
Print Chr(10) & Space(1 + i \ 2);
Next
End Sub
扩展资料:
在VB中,注释有2种方式。
1、以Rem关键字开头,并且Rem关键字与注释内容之间要加一个空格。注释可以是单独的一行,也可以写在其他语句行的后面。如果在其他语句行后使用Rem关键字,则必须使用冒号(:)与语句隔开。
2、使用一个撇号(')来代替Rem关键字。若使用撇号,则在其他语句行使用时不必加冒号。
特征衡量
在 Visual Basic 中,可通过属性、方法和事件来说明和衡量一个对象的特征。
参考资料来源:百度百科-Visual Basic
例如:Private Sub Command1_Click()
If Text1 = "" Then MsgBox "请输入关键字"
WebBrowser1.SetFocus '先得到焦点
SendKeys Text1 '发送
SendKeys "{enter}" '回车
End Sub
Private Sub Form_Load()
Text1 = ""
Command1.Caption = "百度一下"
WebBrowser1.Navigate "www.baidu.com"
End Sub
补充:Visual Basic是一种由微软公司开发的包含协助开发环境的事件驱动编程语言。从任何标准来说,VB都是世界上使用人数最多的语言——不仅是盛赞VB的开发者还是抱怨VB的开发者的数量。它源自于BASIC编程语言。VB拥有图形用户界面(GUI)和快速应用程序开发(RAD)系统,可以轻易的使用DAO、RDO、ADO连接数据库,或者轻松的创建ActiveX控件。程序员可以轻松的使用VB提供的组件快速建立一个应用程序。
show
Dim m, n, i, j As Integer
m = 4 :n = 7
For i = 1 To m
For j = 1 To m - i + 1
Print " ";
Next j
For j = 1 To n
Print "*";
Next j
Next i
For i = 1 To m
For j = 1 To m - i + 1
Print " ";
Next j
For j = 1 To 2 * i - 1
Print "*";
Next j
Next i
For i = 1 To m
For j = 1 To i
Print " ";
Next j
For j = 1 To 2 * m - 2 * i + 1
Print "*";
Next j
Next i
End Sub
m = 6 '行数
n = 11 '平行四边形每行的*数目
Cls
For i = 1 To m
For j = 1 To m - i + 1
Print " ";
Next
For j = 1 To n
Print "*";
Next
Next
For i = 1 To m
For j = 1 To m - i + 1
Print " ";
Next
For j = 1 To 2 * i - 1
Print "*";
Next
Next
For i = 1 To m
For j = 1 To i
Print " ";
Next
For j = 1 To 2 * m - 2 * i + 1
Print "*";
Next
Next
End Sub
广告 您可能关注的内容 |