简易编程vb
㈠ VB编程(比较简单的)
Dim m As Integer
Dim n As Integer
Dim R As Integer
m = Val(Text1.Text)
n = Val(Text2.Text)
R = m Mod n
Do While R <> 0
m = n
n = R
R = m Mod n
Loop
Text3.Text = n
㈡ VB编程,超简单的。求编写代码
第一题:
Private Sub Form_Click()
Dim x As Double, Y As Double
x = InputBox("请输入当前顾客购买鸡蛋的重量(以公斤为单位)")
If x < 3 Then
Y = 7.6 * x
Else
Y = 7.6 * x * 0.8
End If
Print Format(Y, "0.00")
End Sub
第二题:
Private Sub Form_Click()
Dim x As Double, Y As Double
x = InputBox("请输入顾客所乘的公里数")
If x / Fix(x) = 1 Then
x = x
Else
x = Fix(x) + 1
End If
If x > 15 Then
Y = 7 + 13 * 1.5 + (x - 15) * 2.1
ElseIf x > 2 Then
Y = 7 + (x - 2) * 1.5
Else
Y = 7
End If
Print Y
End Sub
㈢ 简单的Vb编程
使用一个嵌套的双层循环就行了
㈣ VB简易程序设计代码
题目一:
Private Sub Text1_Change()
Text2.Text = Text1.Text
End Sub
题目二:
Private Sub Command1_Click()
Text1.Text = "程序设计第一步:设计界面"
End Sub
Private Sub Command2_Click()
Text1.Text = "程序设计第二步:属性设置"
End Sub
Private Sub Command3_Click()
Text1.Text = "程序设计第三步:编写代码"
End Sub
题目三:
Private Sub Command1_Click()
Text1.PasswordChar = "*"
End Sub
题目四:
运行结果:
23
23
23
hellonihao
hellonihao
hello 100
helloI
100nihao
Inihao
..........先写这么多 - - 先睡觉去了。。。明儿再说!
㈤ 简单VB编程(来看看)
Private Function GetNumberString(strNumber As String) As String
Dim i As Integer
Dim j As Integer
Dim strResult
Dim count(1 To 9) As Integer
For i = 1 To 9
count(i) = 0
Next i
For i = 1 To Len(strNumber)
For j = 1 To Len(strNumber)
If Mid(strNumber, i, 1) = Mid(strNumber, j, 1) And count(CInt(Mid(strNumber, j, 1))) = 0 Then
strResult = strResult & Mid(strNumber, j, 1)
count(CInt(Mid(strNumber, j, 1))) = 1
End If
Next j
Next i
GetNumberString = strResult
End Function
我给你封装的函数,具有通用性,这个函数会把重复的数字去掉,只留下不重复的
㈥ 简单的VB编程
Private Sub Command1_Click()
If Combo1.Text = "生活用水" Then
Text2 = Val(Text1) * 1 & "元"
ElseIf Combo1.Text = "工业用水" Then
Text2 = Val(Text1) * 5 & "元"
End If
End Sub
Private Sub Form_Load()
Combo1.AddItem "生活用水"
Combo1.AddItem "工业用水"
Label1.Caption = "使用吨数"
Label2.Caption = "应缴水费:"
Text1 = ""
Text2 = ""
Combo1.ListIndex = 0
Command1.Caption = "计算"
End Sub
㈦ vb编程超简单
PrivateSubCommand1_Click()
Text2.Text=""
Text2.Text=Text2.Text+Text1.Text
Fori=0To2
IfOption1(i).Value=TrueThen
Text2.Text=Text2.Text+Space(3)+"职称:"+Option1(i).Caption+Space(3)
Else
Option1(i).Enabled=False
EndIf
Nexti
Text2.Text=Text2.Text+"爱好:"
Fori=0To2
IfCheck1(i).Value=1Then
Text2.Text=Text2.Text+Check1(i).Caption+Space(1)
Else
Check1(i).Enabled=False
EndIf
Nexti
Text2.Text=Text2.Text+Space(2)+"籍贯:"+List1.List(List1.ListIndex)+Space(3)
Text2.Text=Text2.Text+"部门:"+Combo1.Text
EndSub
PrivateSubCommand2_Click()
End
EndSub
PrivateSubForm_Load()
Option1(0).Caption="初级"
Option1(1).Caption="中级"
Option1(2).Caption="高级"
Check1(0).Caption="音乐"
Check1(1).Caption="体育"
Check1(2).Caption="绘画"
List1.AddItem"北京市"
List1.AddItem"江苏省"
List1.AddItem"江西省"
List1.AddItem"山东省"
List1.AddItem"山西省"
List1.AddItem"浙江省"
List1.AddItem"辽宁省"
List1.AddItem"天津市"
List1.AddItem"湖南省"
List1.AddItem"河北省"
List1.AddItem"上海市"
List1.AddItem"广东省"
Combo1.AddItem"电子系"
Combo1.AddItem"数学系"
Combo1.AddItem"计算机系"
Combo1.AddItem"物理系"
Combo1.AddItem"化学系"
Combo1.AddItem"天文系"
Combo1.AddItem"地质系"
Combo1.AddItem"医学系"
Text1.Text=""
Text2.Text=""
EndSub
PrivateSubFrame1_Click()
Fori=0To2
IfOption1(Index).Value=FalseThenOption1(Index).Enabled=False
Nexti
EndSub
㈧ 简单VB编程
就5分???
㈨ vb编程(很简单的)
作业还是尽可能自己完成呀!
既然“很简单的”,自己写呀?何必求别人写?还望眼欲穿,在这里苦苦地等呢?
下不为例哈!
Dim a
Private Sub Command1_Click()
a = 0
Lop:
If a < 100 Then
a = a + 1
If Int(a / 7) * 7 = a Then
Print a
End If
GoTo Lop
Else:
End If
End Sub
㈩ 急求!!!!!!!!简易VB编程
我已经测试成功,非常正确!!随便你怎么测试,我已经给你标上了详细的注释..
两个text文本框 text1是输入的字串,text2是输出的颠倒的字串.还有一个command.
command下的代码是:
Private Sub Command1_Click()
Dim BeginStr As String, MiddleStr As String, EndStr As String
Dim L As Long, Str As String, s() As String
L = Len(Text1.Text) '检测字串的位数
If (L Mod 2) = 0 Then '如果是偶数位的字串
'如果是偶数位就将中间的字串定位2位
Str = Mid(Text1.Text, (L / 2), 2)
s = Split(Text1.Text, Str)
Text2.Text = s(1) & Str & s(0) '将数据颠倒重组
Else '如果是奇数位的字串
'如果是奇数位的字串中间的字串肯定就是1位了
Str = Mid(Text1.Text, (L + 1) / 2, 1)
s = Split(Text1.Text, Str)
Text2.Text = s(1) & Str & s(0) '将数据颠倒重组
End If
End Sub