加法运算主要部分代码:Text3.Text = Val(Text1.Text) + Val(Text2.Text)

除法:If Val(Text2.Text) = 0 Then
MsgBox "除数不能为零"
Else
Text3 = Val(Text1) / (Text2)
     
End If
End Sub

润年:Private Sub Command1_Click()
Dim year As Integer
year = Val(Text1)
If year Mod 4 = 0 And year Mod 100 <> 0 Or year Mod 400 = 0 Then
 MsgBox "不是"
 Else
 MsgBox "是"
 End If

End Sub
 

三角形面积方法一:Private Sub Command1_Click()
Dim a As Single
Dim b As Single
Dim c As Single
Dim p As Single
Dim s As Single

a = InputBox("a=", "请输入a的数值")
b = InputBox("b=", "请输入b的数值")
c = InputBox("c=", "请输入c的数值")

If a <= 0 Or b <= 0 Or c <= 0 Or a + b <= c Or a + c <= b Or b + c <= a Then
MsgBox "非三角形的3边"
Else
p = (a + b + c) / 2
s = (p * (p - a) * (p - b) * (p - c)) ^ 0.5
MsgBox "三角形面积S=" & Str(s), vbInformation, "三角形面积"
End If

End Sub

三角形面积方法二:

Dim a As single, b As single, c As singel,d As single, h As single

a=val(text1)

b=val(text2)

c=val(text3)

If a <= 0 Or b <= 0 Or c <= 0 Or a + b <= c Or a + c <= b Or b + c <= a 

h=(a+b+c)/2

d=sqr(h*(h-a)*(h-b)*(h-c))

else

mgbox "不能构成三角形"

end if  

10的阶层
Private Sub Command1_Click()
Dim i As Integer
sum = 1
For i = 1 To 10
sum = sum * i
Next i
Text1 = sum

End Sub

1到100的和

Dim sum As Integer
Dim I As Integer,sum As Interger
sum=0
for i=1 to 100
sum=sum+i
next i
text1=sum

         *
      * * *
    * * * * *
  * * * * * * *
* * * * * * * * *
Private Sub Command1_Click()
For i = 1 To 5
For h = 5 - i To 1 Step -1
Print Spc(3);
Next h
For j = 1 To 2 * i - 1
Print " * ";
Next j
Print
Next i
End Sub

*

**

***

****

*****

for i=1 to 5

 for j=1 to i

print " * ";

next j

print

next i

冒泡排序
For i = 0 To List1.ListCount - 1
List2.AddItem List1.List(i)
Next i
For i = 0 To List2.ListCount - 2
For j = i + 1 To List2.ListCount - 1
If Val(List2.List(i)) > Val(List2.List(j)) Then
t = List2.List(i)
List2.List(i) = List2.List(j)
List2.List(j) = t
End If
Next j
Next i


End Sub
初始化 排序
Dim a(10) As Integer

Private Sub Command1_Click()
Randomize
For i = 1 To 10
a(i) = Int(Rnd * 100)
Print a(i);
Next i
Print
End Sub

Private Sub Command2_Click()
For i = 1 To 9
For j = i + 1 To 10
If a(i) > a(j) Then
   a(0) = a(i)
   a(i) = a(j)
   a(j) = a(0)
   End If
   Next j
   Next i
   For i = 1 To 10
        Print a(i);
    Next i

   print

  End Sub

 倒计时钟程序
Dim m As Long
Private Sub Command1_Click()

Timer1.Enabled = True
m = Val(Text1.Text) * 60
Label1.Caption = "现在开始倒计时"
Command1.Visible = False
 Text1 = m
End Sub

Private Sub Timer1_Timer()
m = m - 1
If m < 0 Then
Timer1.Enabled = False
MsgBox "时间到!", 0, "倒计时"
Label1.Caption = "请输入倒计时的分钟数"
Text1.Text = ""
Command1.Visible = True
Else
Text1.Text = m
End If
End Sub
除法
Private Sub Command1_Click()
If Val(Text2) = 0 Then
MsgBox "除数不能为零"
Else
   Text3 = Val(Text1) / Val(Text2)
Private Sub Command1_Click()
 小时、分钟、秒
Dim i As Long
 i = Val(3600 * Text1) + Val(60 * Text2) + Val(1 * Text1)
 Print i

   End If
End Sub
弧度转化角度
text2=val (text1) * 180 /3.14

1到a 的阶层

Private Sub Command1_Click()
Dim f, s As Long
Dim a As Integer
a = Val(Text1)
For i = 1 To a
f = 1
For j = 1 To i
f = f * j
Next j
s = s + f
Next i
Text2 = s
End Sub

倒三角形
Private Sub Command1_Click()
For i = 5 To 1 Step -1
For h = 4 To i Step -1
Print Spc(3);
Next h
For j = 2 * i - 1 To 1 Step -1
Print " * ";
Next j
Print
Next i
End Sub