商城首页欢迎来到中国正版软件门户

您的位置:首页 > 软件教程 >使用VB编写一个函数或子程序来计算实数变量r的面积

使用VB编写一个函数或子程序来计算实数变量r的面积

  发布于2025-01-17 阅读(150)

扫一扫,手机访问

用VB编写一个通用或子程序过程area以实型变量r作为形参计

用VB编写一个通用或子程序过程area以实型变量r作为形参计

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

#include

#include

#include

#define PI 3.14

floatarea(intdata);

intmain(void)

{

inti;

floatnum;

scanf("%d",&i);

num=area(i);

printf("面积%f:",num);

}

floatarea(intdata)

{

inttest;

floath;

tset=data;

h=PI*pow(test,2);

returnh;

}

1

vb程序设计猜数游戏

Dim a As Byte

Dim b As Byte '回车次数

Private Sub Command1_Click()

Randomize

a = Int(Rnd * 100 + 1)

Command1.Enabled = False

b = 0

End SubPrivate Sub Text1_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 And Command1.Enabled = False Then

If b = 10 Then

Label2.Caption = "运气真差!请重新出题!"

Text1.Enabeld = False

Command1.Enabled = True

Exit Sub

End If

If Val(Text1.Text) = a Then

Command1.Enabled = True

Label2.Caption = "正确"

ElseIf Val(Text1.Text) Label2.Caption = "太小"

b = b + 1

ElseIf Val(Text1.Text) > a Then

Label2.Caption = "太大"

b = b + 1

End If

End If

End Sub

用vb编写一个计算器程序实现加减乘除

Dim v As Boolean

Dim s As Integer

Dim X As Double

Dim Y As Double

Private Sub Command1_Click(Index As Integer)

If Form1.Tag = "T" Then

If Index = 10 Then

Text1.Text = "0"

Else

Text1.Text = Command1(Index).Caption

End If

Form1.Tag = ""

Else

Text1.Text = Text1.Text & Command1(Index).Caption

End If

End Sub

Private Sub Command2_Click(Index As Integer)

Form1.Tag = "T"

If v Then

X = Val(Text1.Text)

v = Not v

Else

Y = Val(Text1.Text)

Select Case s

Case 0

Text1.Text = X + Y

Case 1

Text1.Text = X - Y

Case 2

Text1.Text = X * Y

Case 3

If Y <> 0 Then

Text1.Text = X / Y

Else

MsgBox ("不能以0为除数")

Text1.Text = X

v = False

End If

Case 4

Y = 0

v = False

End Select

X = Val(Text1.Text)

End If

s = Index

End Sub

Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)

End Sub

控件自己添加吧,空间名要和代码名一致

本文转载于:https://www.docexcel.net/show/30_1706.html 如有侵犯,请联系admin@zhengruan.com删除

热门关注