编一个完整的程序 vb
新建一个窗体,画2个文本框 Text1和Text2,代码放在窗体里面...
Option Explicit
Dim arrPY
Private Sub Form_Load()
Text1.Text = ""
Text1.MaxLength = 2
Text2.Text = ""
Text2.Locked = True
arrPY = Array("ling", "yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu", "shi")
End Sub
Private Sub Text1_Change()
'只有一位数字
If Len(Text1) = 1 Then
'校验是否为数字
If IsNumeric(Text1) = False Then Exit Sub
Text2.Text = arrPY(Text1)
Else
'两个数字
'校验数据是否正确
If IsNumeric(Left$(Text1, 1)) = False Or IsNumeric(Right$(Text1, 1)) = False Then Exit Sub
'10就是shi 不能是 yi shi
If Text1 = 10 Then
Text2.Text = arrPY(10)
'以0结尾
ElseIf Right$(Text1, 1) = 0 Then
Text2.Text = arrPY(Left$(Text1, 1)) & " " & arrPY(10)
'其它情况 x shi y
Else
Text2.Text = arrPY(Left$(Text1, 1)) & " " & arrPY(10) & " " & arrPY(Right$(Text1, 1))
End If
End If
End Sub
Private Sub Command1_Click() Dim ScoreRank(4) As String ScoreRank(0) = "0-59:" ScoreRank(1) = "60-69:" ScoreRank(2) = "70-79:" ScoreRank(3) = "80-89:" ScoreRank(4) = "90-100:" Dim Total As Single, Average As Single, Variance As Single Dim Score(19) As Single, Count(4) As Integer Cls Randomize For i = LBound(Score) To UBound(Score) Score(i) = Int(Rnd(i + 1) * 101) Total = Total + Score(i) If Score(i) Score(i) Then t = Score(i) Score(i) = Score(j) Score(j) = t End If Next j Next i For i = LBound(Score) To UBound(Score) Print Score(i); If (i + 1) Mod 10 = 0 Then Print Next i Print For i = LBound(Count) To UBound(Count) Print ScoreRank(i) & Count(i) Next i Print Average = Total / (UBound(Score) + 1) Print "Average="; Average For i = LBound(Score) To UBound(Score) Variance = Variance + (Score(i) - Average) ^ 2 Next i Print "Variance="; VarianceEnd Sub
产生10个串 :m10
最长串 :maxl
字体 :mfontname
保存: mFileSave
结束 :exit
菜单二: menu2
Dim a(1 To 10)
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub exit_Click()
Unload Me
End Sub
Private Sub m10_Click()
Randomize
For i = 1 To 10
num = Int(20 * Rnd + 1)
For j = 1 To num
chr1 = Int(26 * Rnd + 65)
a(i) = a(i) & Chr(chr1)
Next
Next
For i = 1 To 10
List1.AddItem a(i)
Next
End Sub
Private Sub maxl_Click()
Max = 1
For i = 1 To 10
If Len(a(i)) > Max Then Max = Len(a(i))
Next
For i = 1 To 10
If Len(a(i)) = Max Then l = i
Next
Label1.Caption = "最长串的长度为:" & Max & " " & a(l)
End Sub
Private Sub menu2_Click()
Form2.Show
End Sub
Private Sub mFileSave_Click()
Open "c:\a.txt" For Output As #1
For i = 1 To 10
Print #1, a(i)
Next
Close
End Sub
Private Sub mfontname_Click()
CommonDialog1.Flags = 3 Or 256
CommonDialog1.ShowFont
List1.ForeColor = CommonDialog1.Color
List1.FontName = CommonDialog1.FontName
End Sub
Private Sub Command1_Click()
Me.BackColor = vbWhite
Form2.Scale (-15, 30)-(15, -30)
Form2.Line (-15, 0)-(15, 0)
Form2.Line (0, -30)-(0, 30)
For i = 1 To 7 * 3.141 Step 0.001
x = i * Cos(i)
y = i * Sin(i)
Form2.PSet (x, y), vbBlue
Next
End Sub
Private Sub Command2_Click()
Form2.Hide
Form1.Show
End Sub
太多..一会儿写不好.
可以写 不想写
巩傅三九: 可以分为三步:第一步:设计程序的界面 这是最有趣的一步,你根据你要实现的功能画出程序的界面,很有点摆积木的味道.第二步:编写代码 最枯燥的一步,根据程序的功能,为每个控件元素编写代码,这一步是程序设计的关键所在.第三步:发布应用程序 为你的程序创建安装项目.如果是自己使用,这一步可忽略.
东源县15051909464: 写一个vb的程序要怎么写? - ?
巩傅三九: 写一个vb的程序需要在VB的集成编程窗口的代码窗口编写,调试.
东源县15051909464: 编写一个VB程序?
巩傅三九: Private Sub Command1_Click()Dim y As IntegerFor y = 2000 To 2050If y Mod 4 = 0 And y Mod 100 <> 0 Or y Mod 400 = 0 ThenText1.Text = Text1.Text & y & "年为闰年" & vbCrLfElseText1.Text = Text1.Text & y & "年非闰年" & vbCrLf...
东源县15051909464: VB 编写 计算程序 - ?
巩傅三九: 既然没人帮你,我就答一下吧,很简单,就一行代码: Print 100 / (1.1 * InputBox("请输入X的值")) 好吧,给你解释一下,InputBox是输入对话框,用于用户输入x的值,上边代码你可以拆开3行 x=InputBox("请输入X的值") y=100 / (1.1...
东源县15051909464: 叙述编写一个VB程序的一般步骤,以及各步骤的方法和意义?
巩傅三九: 编写VB程序一般分为四个步骤: (1)绘画(设置)程序界面; (2)设置界面控件属性; (3)运行并测试程序; (4)保存,生成可执行exe文件.
东源县15051909464: 编写一个VB程序 - ?
巩傅三九: Private Sub Command1_Click() Dim ScoreRank(4) As String ScoreRank(0) = "0-59:" ScoreRank(1) = "60-69:" ScoreRank(2) = "70-79:" ScoreRank(3) = "80-89:" ScoreRank(4) = "90-100:" Dim Total As Single, Average As Single, ...
东源县15051909464: 用vb编写一个简单的程序 - ?
巩傅三九: 新建一个窗体,画2个文本框 Text1和Text2,代码放在窗体里面...Option Explicit Dim arrPYPrivate Sub Form_Load()Text1.Text = ""Text1.MaxLength = 2Text2.Text = ""Text2.Locked = True arrPY = Array("ling", "yi", "er", "san...
东源县15051909464: 怎么编一个VB代码??
巩傅三九: VB有很多子类,看你的需要去使用不同的IDE环境. 当我们只需要实现一些简单的功能而不必需要窗体和编译为独立的EXE文件的时候,你可以选择用Windows自带的notepad记事本来编写一段vbscript脚本,当然你也可以选用其他任何的文本编辑器. 如果你需要实现Office,如Word、Excel、PowerPoint等程序的自动化操作时,你可以在Office中自带的“宏 Visual Basic”编辑器中撰写代码. 当你需要编写一个功能完整的应用程序时,你得使用Microsoft公司为程序员提供的可视化开发工具Visual Basic 6.0.
东源县15051909464: 求VB编写程序的步骤 - ?
巩傅三九: 基本上所有的程序都是这样的步骤1.设计(包括功能设计,算法设计等)2.添加和建立需要的框体(比如窗体,建立类等)3.进行代码添加4.进行测试
东源县15051909464: 怎样编写VB程序?
巩傅三九: 新建一个工程 放两个按钮,有一个文件框 在按钮1中双击,然后写上text1.text="你点击了 按钮1" 在按钮2中双击,然后写上text1.text="你点击了 按钮2" 运行看下