发布时间:2023-11-11 03:55来源:www.sf1369.com作者:宇宇
第一题:2种代码
vb.net版本
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a, b, c, d, x, y As Single
a = Val(TextBox1.Text)
b = Val(textbox2.text)
c = Val(textbox3.text)
d = Val(textbox4.text)
x = Val(textbox5.text)
y = a * x ^ 3 + b * x ^ 2 + c * x + d
label1.text=y
End Sub
===================================================
vb6.0 版本
Private Sub Command1_Click()
Text6.Text = JiSuan(Val(Text1.Text), Val(Text2.Text), Val(Text3.Text), Val(Text4.Text), Val(Text5.Text))
End Sub
Function JiSuan(a As Long, b As Long, c As Long, d As Long, x As Long) As Long
JiSuan = a * x ^ 3 + b * x ^ 2 + c * x + d
End Function
===================================
第二题
vb.net版本
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListBox1.Items.Add(1)
ListBox1.Items.Add(2)
ListBox1.Items.Add(3)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ListBox1.SelectedIndex > -1 Then
ListBox2.Items.Add(ListBox1.Text)
ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If
End Sub
==========================
vb6.0版本
Private Sub Command1_Click()
If List1.ListIndex > -1 Then
List2.AddItem List1.Text
List1.RemoveItem List1.ListIndex
End If
End Sub
Private Sub Form_Load()
List1.AddItem 1
List1.AddItem 2
List1.AddItem 3
End Sub
这个程序是这样,执行后会显示一个窗口(Frame),窗口的类名叫WindowExit,创口上方有一个菜单栏(MenuBar),类名字叫menubar, 菜单栏有五个菜单项menu1,menu2,menu3,menu4,menu5,对于第一个菜单项menu1又包含有九个子项item1,item2,item3,item4,item5,item6,item7,item8,item9
而item5.addActionListener(this); 则是给第五个子项加一个事件监听器,监听对象为(this)自身类的对象
public void actionPerformed(ActionEvent e)
{ System.exit(0); }
} 这句是是为这个监听器作处理程序,处理结果为关闭窗口!也就是点击item5,则整个WindowExit窗口关闭!
public class zuoye1
{ public static void main(String args[])
{ WindowExit win=new WindowExit();
}
}是整个程序的主类和主函数的入口程序!