簡易編程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