题目
用VB画圆、正方形、长方形、球、正方体、长方体
要编程的内容过程
最好编程简单点
否则以我的程度 怕看不懂
要编程的内容过程
最好编程简单点
否则以我的程度 怕看不懂
提问时间:2021-01-25
答案
画圆
VERSION 5.00
Begin VB.Form FMain
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 5205
ClientLeft = 45
ClientTop = 330
ClientWidth = 7035
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5205
ScaleWidth = 7035
StartUpPosition = 2 '屏幕中心
Begin VB.CheckBox chkA
Caption = "自动反转"
Height = 375
Left = 5280
TabIndex = 5
Top = 3600
Width = 1695
End
Begin VB.CheckBox chkAuto
Caption = "自动旋转"
Height = 255
Left = 5280
TabIndex = 4
Top = 3240
Width = 1575
End
Begin VB.Timer tmrTurn
Enabled = 0 'False
Interval = 100
Left = 5280
Top = 4080
End
Begin VB.PictureBox picDraw
Height = 5000
Left = 120
ScaleHeight = 4935
ScaleWidth = 4935
TabIndex = 3
Top = 120
Width = 5000
End
Begin VB.CommandButton cmdTurnAnti
Caption = "正向"
Height = 495
Left = 5280
TabIndex = 2
Top = 1200
Width = 1575
End
Begin VB.TextBox txtAngle
Height = 375
Left = 5280
TabIndex = 1
Text = "30"
Top = 120
Width = 1575
End
Begin VB.CommandButton cmdTurn
Caption = "反向"
Height = 495
Left = 5280
TabIndex = 0
Top = 600
Width = 1575
End
End
Attribute VB_Name = "FMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const rPI As Single = 3.14159265358979
Private iAngle As Integer '转过角度
Private Sub chkAuto_Click()
tmrTurn.Enabled = chkAuto.Value
End Sub
Private Sub cmdTurn_Click()
iAngle = iAngle + Val(txtAngle.Text)
Call Draw
End Sub
Private Sub cmdTurnAnti_Click()
iAngle = iAngle - Val(txtAngle.Text)
Call Draw
End Sub
Private Sub Form_Load()
picDraw.Scale (-1, 1)-(1, -1) '中心设为原点
picDraw.DrawWidth = 5 '加粗
End Sub
Private Sub Draw()
picDraw.Cls
picDraw.Line (0, 0)-(Cos(iAngle / 180 * rPI), Sin(iAngle / 180 * rPI))
End Sub
Private Sub tmrTurn_Timer()
If chkA.Value = 0 Then
Call cmdTurnAnti_Click
Else
Call cmdTurn_Click
End If
End Sub
矩形
Public Sub DrawRectangle(ByVal Width As Long, ByVal Height As Long, Optional Top As Long, Optional Left As Long)
Line (Left, Top)-(Left + Width, Top)
Line (Left, Top)-(Left, Top + Height)
Line (Left, Top + Height)-(Left + Width, Top + Height)
Line (Left + Width, Top)-(Left + Width, Top + Height)
End Sub
球
定义一个数组记录某一个值是不是已经被使用
比如有10个数供选择,那就定义a[10],赋初值0,表示没有使用,当抽取一个号码后,比如是5,那就令a[5-1]=1,求救已经使用,每次取数时判断一下取得的数i对应的a[i]是否等于0就可以了.
长方体
Private Type xyz '定义3D坐标类型
y As Single
z As Single
End Type
Private xyz1() As xyz
Public x0 As Single, y0 As Single, x1 As Single, y1 As Single
Private Sub Check1_Click()
If x1 = 0 Or y1 = 0 Then
Exit Sub
End If
If Check1.Value = 1 Then '如果选择显示空间坐标轴,就画出空间坐标轴
Line (x1, y1)-(x1, y1 - 6400)
Line (x1, y1)-(x1 + 6400, y1)
Line (x1, y1)-(x1 - 4050, y1 + 4050)
Line (x1, y1 - 6400)-(x1 - 200, y1 - 6200)
Line (x1, y1 - 6400)-(x1 + 200, y1 - 6200)
Line (x1 + 6400, y1)-(x1 + 6200, y1 + 200)
Line (x1 + 6400, y1)-(x1 + 6200, y1 - 200)
Line (x1 - 4050, y1 + 4050)-(x1 - 4050, y1 + 3850)
Line (x1 - 4050, y1 + 4050)-(x1 - 3850, y1 + 4050)
Else
Cls
End If
End Sub
Private Sub Command1_Click()
drawpnt Val(Text1.Text), Val(Text2.Text), Val(Text3.Text) '这是在三维空间画点的事件
End Sub
Private Sub Command2_Click()
Call VScroll1_Change(0) '画长方体
End Sub
Private Sub Command3_Click()
dmove 0, 500, 0 '移动
End Sub
Private Sub Command4_Click()
dmove -500, 0, 0 '移动
End Sub
Private Sub Command5_Click()
dmove 500, 0, 0 '移动
End Sub
Private Sub Command6_Click()
dmove 0, -500, 0 '移动
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Cls
x0 = x
y0 = y
x1 = x
y1 = y
Call Check1_Click
ReDim xyz1(0 To 1)
xyz1(0).y = x
xyz1(0).z = y
PSet (x, y)
'在程序上点击鼠标画出空间坐标轴,并记录原点
End Sub
Sub drawpnt(dx As Single, dy As Single, dz As Single)
Dim dxy As Single
dxy = Fix(dx * Sqr(2) / 2)
xyz1(0).y = x0 - dxy + dy
xyz1(0).z = y0 + dxy - dz
PSet (xyz1(0).y, xyz1(0).z)
'画点的过程
End Sub
Sub dline(dx1 As Single, dy1 As Single, dz1 As Single, dx2 As Single, dy2 As Single, dz2 As Single)
Dim dxy1 As Single, dxy2 As Single
dxy1 = Fix(dx1 * Sqr(2) / 2)
dxy2 = Fix(dx2 * Sqr(2) / 2)
xyz1(0).y = x0 - dxy1 + dy1
xyz1(0).z = y0 + dxy1 - dz1
xyz1(1).y = x0 - dxy2 + dy2
xyz1(1).z = y0 + dxy2 - dz2
Line (xyz1(0).y, xyz1(0).z)-(xyz1(1).y, xyz1(1).z)
'划线的过程
End Sub
Private Sub VScroll1_Change(index As Integer)
If x0 = 0 Or y0 = 0 Then
Exit Sub
End If
Cls
Call Check1_Click
Dim a As Single, b As Single, c As Single
a = VScroll1(0).Value * 900
b = VScroll1(1).Value * 900
c = VScroll1(2).Value * 900
square a, b, c
'根据a,b,c(长,宽,高)来画长方体的过程
End Sub
Sub square(a As Single, b As Single, c As Single)
dline 0, 0, 0, a, 0, 0
dline 0, 0, 0, 0, b, 0
dline 0, 0, 0, 0, 0, c
dline a, 0, 0, a, b, 0
dline a, 0, 0, a, 0, c
dline 0, b, 0, a, b, 0
dline 0, b, 0, 0, b, c
dline 0, 0, c, a, 0, c
dline 0, 0, c, 0, b, c
dline a, b, c, a, b, 0
dline a, b, c, a, 0, c
dline a, b, c, 0, b, c
End Sub
Sub dmove(dx As Single, dy As Single, dz As Single)
If x0 = 0 Or y0 = 0 Then
Exit Sub
End If
Cls
Call Check1_Click
x0 = x0 + dx
y0 = y0 - dy
Call VScroll1_Change(0)
'移动长方体的过程
End Sub
正方体和长方体的原理一样,写不动啦!
VERSION 5.00
Begin VB.Form FMain
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 5205
ClientLeft = 45
ClientTop = 330
ClientWidth = 7035
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5205
ScaleWidth = 7035
StartUpPosition = 2 '屏幕中心
Begin VB.CheckBox chkA
Caption = "自动反转"
Height = 375
Left = 5280
TabIndex = 5
Top = 3600
Width = 1695
End
Begin VB.CheckBox chkAuto
Caption = "自动旋转"
Height = 255
Left = 5280
TabIndex = 4
Top = 3240
Width = 1575
End
Begin VB.Timer tmrTurn
Enabled = 0 'False
Interval = 100
Left = 5280
Top = 4080
End
Begin VB.PictureBox picDraw
Height = 5000
Left = 120
ScaleHeight = 4935
ScaleWidth = 4935
TabIndex = 3
Top = 120
Width = 5000
End
Begin VB.CommandButton cmdTurnAnti
Caption = "正向"
Height = 495
Left = 5280
TabIndex = 2
Top = 1200
Width = 1575
End
Begin VB.TextBox txtAngle
Height = 375
Left = 5280
TabIndex = 1
Text = "30"
Top = 120
Width = 1575
End
Begin VB.CommandButton cmdTurn
Caption = "反向"
Height = 495
Left = 5280
TabIndex = 0
Top = 600
Width = 1575
End
End
Attribute VB_Name = "FMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Const rPI As Single = 3.14159265358979
Private iAngle As Integer '转过角度
Private Sub chkAuto_Click()
tmrTurn.Enabled = chkAuto.Value
End Sub
Private Sub cmdTurn_Click()
iAngle = iAngle + Val(txtAngle.Text)
Call Draw
End Sub
Private Sub cmdTurnAnti_Click()
iAngle = iAngle - Val(txtAngle.Text)
Call Draw
End Sub
Private Sub Form_Load()
picDraw.Scale (-1, 1)-(1, -1) '中心设为原点
picDraw.DrawWidth = 5 '加粗
End Sub
Private Sub Draw()
picDraw.Cls
picDraw.Line (0, 0)-(Cos(iAngle / 180 * rPI), Sin(iAngle / 180 * rPI))
End Sub
Private Sub tmrTurn_Timer()
If chkA.Value = 0 Then
Call cmdTurnAnti_Click
Else
Call cmdTurn_Click
End If
End Sub
矩形
Public Sub DrawRectangle(ByVal Width As Long, ByVal Height As Long, Optional Top As Long, Optional Left As Long)
Line (Left, Top)-(Left + Width, Top)
Line (Left, Top)-(Left, Top + Height)
Line (Left, Top + Height)-(Left + Width, Top + Height)
Line (Left + Width, Top)-(Left + Width, Top + Height)
End Sub
球
定义一个数组记录某一个值是不是已经被使用
比如有10个数供选择,那就定义a[10],赋初值0,表示没有使用,当抽取一个号码后,比如是5,那就令a[5-1]=1,求救已经使用,每次取数时判断一下取得的数i对应的a[i]是否等于0就可以了.
长方体
Private Type xyz '定义3D坐标类型
y As Single
z As Single
End Type
Private xyz1() As xyz
Public x0 As Single, y0 As Single, x1 As Single, y1 As Single
Private Sub Check1_Click()
If x1 = 0 Or y1 = 0 Then
Exit Sub
End If
If Check1.Value = 1 Then '如果选择显示空间坐标轴,就画出空间坐标轴
Line (x1, y1)-(x1, y1 - 6400)
Line (x1, y1)-(x1 + 6400, y1)
Line (x1, y1)-(x1 - 4050, y1 + 4050)
Line (x1, y1 - 6400)-(x1 - 200, y1 - 6200)
Line (x1, y1 - 6400)-(x1 + 200, y1 - 6200)
Line (x1 + 6400, y1)-(x1 + 6200, y1 + 200)
Line (x1 + 6400, y1)-(x1 + 6200, y1 - 200)
Line (x1 - 4050, y1 + 4050)-(x1 - 4050, y1 + 3850)
Line (x1 - 4050, y1 + 4050)-(x1 - 3850, y1 + 4050)
Else
Cls
End If
End Sub
Private Sub Command1_Click()
drawpnt Val(Text1.Text), Val(Text2.Text), Val(Text3.Text) '这是在三维空间画点的事件
End Sub
Private Sub Command2_Click()
Call VScroll1_Change(0) '画长方体
End Sub
Private Sub Command3_Click()
dmove 0, 500, 0 '移动
End Sub
Private Sub Command4_Click()
dmove -500, 0, 0 '移动
End Sub
Private Sub Command5_Click()
dmove 500, 0, 0 '移动
End Sub
Private Sub Command6_Click()
dmove 0, -500, 0 '移动
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
Cls
x0 = x
y0 = y
x1 = x
y1 = y
Call Check1_Click
ReDim xyz1(0 To 1)
xyz1(0).y = x
xyz1(0).z = y
PSet (x, y)
'在程序上点击鼠标画出空间坐标轴,并记录原点
End Sub
Sub drawpnt(dx As Single, dy As Single, dz As Single)
Dim dxy As Single
dxy = Fix(dx * Sqr(2) / 2)
xyz1(0).y = x0 - dxy + dy
xyz1(0).z = y0 + dxy - dz
PSet (xyz1(0).y, xyz1(0).z)
'画点的过程
End Sub
Sub dline(dx1 As Single, dy1 As Single, dz1 As Single, dx2 As Single, dy2 As Single, dz2 As Single)
Dim dxy1 As Single, dxy2 As Single
dxy1 = Fix(dx1 * Sqr(2) / 2)
dxy2 = Fix(dx2 * Sqr(2) / 2)
xyz1(0).y = x0 - dxy1 + dy1
xyz1(0).z = y0 + dxy1 - dz1
xyz1(1).y = x0 - dxy2 + dy2
xyz1(1).z = y0 + dxy2 - dz2
Line (xyz1(0).y, xyz1(0).z)-(xyz1(1).y, xyz1(1).z)
'划线的过程
End Sub
Private Sub VScroll1_Change(index As Integer)
If x0 = 0 Or y0 = 0 Then
Exit Sub
End If
Cls
Call Check1_Click
Dim a As Single, b As Single, c As Single
a = VScroll1(0).Value * 900
b = VScroll1(1).Value * 900
c = VScroll1(2).Value * 900
square a, b, c
'根据a,b,c(长,宽,高)来画长方体的过程
End Sub
Sub square(a As Single, b As Single, c As Single)
dline 0, 0, 0, a, 0, 0
dline 0, 0, 0, 0, b, 0
dline 0, 0, 0, 0, 0, c
dline a, 0, 0, a, b, 0
dline a, 0, 0, a, 0, c
dline 0, b, 0, a, b, 0
dline 0, b, 0, 0, b, c
dline 0, 0, c, a, 0, c
dline 0, 0, c, 0, b, c
dline a, b, c, a, b, 0
dline a, b, c, a, 0, c
dline a, b, c, 0, b, c
End Sub
Sub dmove(dx As Single, dy As Single, dz As Single)
If x0 = 0 Or y0 = 0 Then
Exit Sub
End If
Cls
Call Check1_Click
x0 = x0 + dx
y0 = y0 - dy
Call VScroll1_Change(0)
'移动长方体的过程
End Sub
正方体和长方体的原理一样,写不动啦!
举一反三
已知函数f(x)=x,g(x)=alnx,a∈R.若曲线y=f(x)与曲线y=g(x)相交,且在交点处有相同的切线,求a的值和该切线方程.
我想写一篇关于奥巴马的演讲的文章,写哪一篇好呢?为什么好
奥巴马演讲不用看稿子.为什么中国领导演讲要看?
想找英语初三上学期的首字母填空练习……
英语翻译
最新试题
- 1有一批货总工是1680不良品是360,请问良率和不良率各是多少
- 2彩虹秀丽凶恶通红朗读叮嘱攀登冰雹北京马路驾驶大厦 恬静抄写端正哪些是名词,哪些是动词,哪些是形容词?
- 3小明新买了一只手表,结果发现比家里的闹钟每小时快30秒,闹钟又比标准时间每小时慢30秒,
- 4非物质文化遗产是什么概念和其实质是什么?
- 5已知5x+3y+2z=2011,4x+6y+7z=2012,求x+y+z的值
- 6塑料水杯下印着三角里是7是什么意思,能放热水吗?
- 7The little boy___by the big one this morning Amade cry Bwas made cry Cmade to cry Dwas made to cry
- 8答的多音字组词
- 9Lucy is good at playing volleyball 改为同义句?
- 10如图,在锐角三角形ABC中,AB>AC,AD垂直于D,以AD为直径的图O分别交AB,AC于E,F
热门考点
- 1这几道题做错了,但是不明白为什么,请帮我讲讲,
- 2只用一种试剂鉴别下列物质,在横线上填所加试剂的化学式或名称 (l)BaCI2 NaCl K2CO3_. (2)NaNO3 MgCl2 (NH4)2SO4_. (3)CaCl2 NaNO3 H2SO4_
- 3在半径为5厘米的圆中,弦AB=6,弦CD=8,且AB‖CD,求AB与CD间的距离.(有两种情况噢)
- 4我校数学活动小组中,女生的人数比男生的人数少二人,如果女生增加三人,男生减少一人,那么女生的人数比全组人数的四分之一多三人,求原来男女生的人数
- 5方程组:①lxI+y=12②x+lyl=6的解(x,y)共有几组?
- 6一个三角形的底是x厘米,高是12厘米,这个三角形的面积是( )平方厘米?
- 7把词语填完整
- 8一个九位数,最高位上是最小的质数,千万位上是最小的合数,千位是最大的一位数,其他各位上都是零,这个数是
- 9分数单位是8/1的最简真分数
- 10人的脑,肺,小肠,胎盘等部位的物质和气体交换异常活跃的部位,所以这些地方( )分布密集,原因是其管壁( )血液速度( ),便于充分地进行物质交换