VB控件数组做多窗体
想用VB做一个输入成绩计算成绩的多窗体界面像这样的在点开输入成绩窗体时,返回按钮要怎么做?界面是编码是PrivateSubCommand1_Click()DimiAsIn...
想用VB做一个输入成绩计算成绩的多窗体界面
像这样的
在点开输入成绩窗体时,返回按钮要怎么做?
界面是
编码是
Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 6
cj(i) = Val(Text(i).Text)
Next
Form2.Hide
Form1.Show
End Sub
为什么运行之后显示子程序或函数未定义? 展开
像这样的
在点开输入成绩窗体时,返回按钮要怎么做?
界面是
编码是
Private Sub Command1_Click()
Dim i As Integer
For i = 1 To 6
cj(i) = Val(Text(i).Text)
Next
Form2.Hide
Form1.Show
End Sub
为什么运行之后显示子程序或函数未定义? 展开
2个回答
推荐于2016-08-13
展开全部
'Form1窗体代码:
Private WithEvents frm2 As Form2
Private cj_value() As Single
Private Sub Command1_Click()
If frm2 Is Nothing Then
Set frm2 = New Form2
End If
frm2.Show
End Sub
Private Sub Form_Load()
Command1.Caption = "输入成绩"
Command2.Caption = "计算成绩"
Command3.Caption = "结束"
End Sub
Private Sub frm2_ReturnValue(cj() As Single)
cj_value = cj
End Sub
'Form2窗体代码
Public Event ReturnValue(cj() As Single)
Private Sub Command1_Click()
Dim i As Integer
Dim cj(5) As Single
For i = 0 To 5
cj(i) = Val(Text1(i).Text)
Next
RaiseEvent ReturnValue(cj) '返回输入值
Unload Me
End Sub
Private Sub Form_Load()
Dim i As Integer, j As Integer
Text1(0).Text = ""
Command1.Caption = "返回"
For i = 1 To 5
Load Text1(i)
Text1(i).Visible = True
If i Mod 2 = 1 Then
Text1(i).Left = Text1(0).Left + 3500
Text1(i).Top = Text1(i - 1).Top
Else
Text1(i).Left = Text1(i).Left
Text1(i).Top = Text1(i - 1).Top + 500
End If
Next
End Sub
Private WithEvents frm2 As Form2
Private cj_value() As Single
Private Sub Command1_Click()
If frm2 Is Nothing Then
Set frm2 = New Form2
End If
frm2.Show
End Sub
Private Sub Form_Load()
Command1.Caption = "输入成绩"
Command2.Caption = "计算成绩"
Command3.Caption = "结束"
End Sub
Private Sub frm2_ReturnValue(cj() As Single)
cj_value = cj
End Sub
'Form2窗体代码
Public Event ReturnValue(cj() As Single)
Private Sub Command1_Click()
Dim i As Integer
Dim cj(5) As Single
For i = 0 To 5
cj(i) = Val(Text1(i).Text)
Next
RaiseEvent ReturnValue(cj) '返回输入值
Unload Me
End Sub
Private Sub Form_Load()
Dim i As Integer, j As Integer
Text1(0).Text = ""
Command1.Caption = "返回"
For i = 1 To 5
Load Text1(i)
Text1(i).Visible = True
If i Mod 2 = 1 Then
Text1(i).Left = Text1(0).Left + 3500
Text1(i).Top = Text1(i - 1).Top
Else
Text1(i).Left = Text1(i).Left
Text1(i).Top = Text1(i - 1).Top + 500
End If
Next
End Sub
更多追问追答
追问
你说的太难了我看不太懂……
WithEvents frm2 这句就不明白啦 我学的是最基础的VB……
追答
cj(i)=val(Text1(i).text),这句Text后是不是少个1
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
cj数组变量没定义
dim cj(1 to 6)
dim cj(1 to 6)
更多追问追答
追问
听你的改了一下,
Private Sub Command1_Click()
Dim i As Integer
Dim cj(1 to 6) As Long
For i = 1 To 6
cj(i) = Val(Text(i).Text)
Next
Form2.Hide
Form1.Show
End Sub
可是怎么还是那个错误?
追答
错误在哪一行?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询