十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
Public Class ks
为昌江等地区用户提供了全套网页设计制作服务,及昌江网站建设行业解决方案。主营业务为做网站、成都网站制作、昌江网站设计,以传统方式定制建设网站,并提供域名空间备案等一条龙服务,秉承以专业、用心的态度为用户提供真诚的服务。我们深信只要达到每一位用户的要求,就会得到认可,从而选择与我们长期合作。这样,我们也可以走得更远!
Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents tx As System.Windows.Forms.TextBox
Friend WithEvents ty As System.Windows.Forms.TextBox
Friend WithEvents tz As System.Windows.Forms.TextBox
Friend WithEvents ok As System.Windows.Forms.Button
Friend WithEvents l1 As System.Windows.Forms.Label
Friend WithEvents l2 As System.Windows.Forms.Label
Friend WithEvents l3 As System.Windows.Forms.Label
System.Diagnostics.DebuggerStepThrough() Private Sub InitializeComponent()
Me.l1 = New System.Windows.Forms.Label
Me.l2 = New System.Windows.Forms.Label
Me.l3 = New System.Windows.Forms.Label
Me.tx = New System.Windows.Forms.TextBox
Me.ty = New System.Windows.Forms.TextBox
Me.tz = New System.Windows.Forms.TextBox
Me.ok = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'l1
'
Me.l1.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte))
Me.l1.Location = New System.Drawing.Point(8, 8)
Me.l1.Name = "l1"
Me.l1.Size = New System.Drawing.Size(200, 16)
Me.l1.TabIndex = 0
'
'l2
'
Me.l2.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte))
Me.l2.Location = New System.Drawing.Point(8, 32)
Me.l2.Name = "l2"
Me.l2.Size = New System.Drawing.Size(200, 16)
Me.l2.TabIndex = 1
'
'l3
'
Me.l3.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte))
Me.l3.Location = New System.Drawing.Point(8, 56)
Me.l3.Name = "l3"
Me.l3.Size = New System.Drawing.Size(200, 16)
Me.l3.TabIndex = 2
'
'tx
'
Me.tx.Location = New System.Drawing.Point(8, 80)
Me.tx.Name = "tx"
Me.tx.Size = New System.Drawing.Size(200, 25)
Me.tx.TabIndex = 3
Me.tx.Text = "请输入x"
'
'ty
'
Me.ty.Location = New System.Drawing.Point(8, 104)
Me.ty.Name = "ty"
Me.ty.Size = New System.Drawing.Size(200, 25)
Me.ty.TabIndex = 4
Me.ty.Text = "请输入y"
'
'tz
'
Me.tz.Location = New System.Drawing.Point(8, 128)
Me.tz.Name = "tz"
Me.tz.Size = New System.Drawing.Size(200, 25)
Me.tz.TabIndex = 5
Me.tz.Text = "请输入z"
'
'ok
'
Me.ok.BackColor = System.Drawing.Color.FromArgb(CType(192, Byte), CType(192, Byte), CType(255, Byte))
Me.ok.Location = New System.Drawing.Point(8, 160)
Me.ok.Name = "ok"
Me.ok.Size = New System.Drawing.Size(200, 64)
Me.ok.TabIndex = 6
Me.ok.Text = "ok"
'
'ks
'
Me.AutoScaleBaseSize = New System.Drawing.Size(8, 18)
Me.BackColor = System.Drawing.Color.FromArgb(CType(128, Byte), CType(128, Byte), CType(255, Byte))
Me.ClientSize = New System.Drawing.Size(216, 232)
Me.Controls.Add(Me.ok)
Me.Controls.Add(Me.tz)
Me.Controls.Add(Me.ty)
Me.Controls.Add(Me.tx)
Me.Controls.Add(Me.l3)
Me.Controls.Add(Me.l2)
Me.Controls.Add(Me.l1)
Me.Name = "ks"
Me.Text = "考试"
Me.ResumeLayout(False)
End Sub
#End Region
Dim x, y, z, a, b, c, d, aa, bb, cc As Single
Dim tts, alls As Single
Private Sub ks_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
x = Int(1 + 30 * Rnd())
y = Int(1 + 20 * Rnd())
z = Int(1 + 25 * Rnd())
a = Int(2 + 4 * Rnd())
b = Int(1 + a * 2 * Rnd())
c = Int(1 + b * 2 * Rnd())
d = Int(1 + c * 3 * Rnd())
aa = x + y + z
bb = a * x + b * y + c * z
cc = b * x + c * y + d * z
l1.Text = "x+y+z=" Str(aa)
l2.Text = Str(a) "x+" Str(b) "y+" Str(c) "z=" Str(bb)
l3.Text = Str(b) "x+" Str(c) "y+" Str(d) "z=" Str(cc)
End Sub
Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click
If Val(tx.Text) = x And Val(ty.Text) = y And Val(tz.Text) = z Then
tts = tts + 1
End If
alls = alls + 1
tx.Text = ""
ty.Text = ""
tz.Text = ""
x = Int(1 + (1000 ^ 0.5) * Rnd())
y = Int(1 + (10000 ^ 0.4) * Rnd())
z = Int(1 + (100000 ^ 0.3) * Rnd())
a = Int(2 + 4 * Rnd())
b = Int(1 + a * 2 * Rnd())
c = Int(1 + b * 2 * Rnd())
d = Int(1 + c * 3 * Rnd())
aa = x + y + z
bb = a * x + b * y + c * z
cc = b * x + c * y + d * z
l1.Text = "x+y+z=" Str(aa)
l2.Text = Str(a) "x+" Str(b) "y+" Str(c) "z=" Str(bb)
l3.Text = Str(b) "x+" Str(c) "y+" Str(d) "z=" Str(cc)
End Sub
Private Sub ks_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click
Dim lv As Single
If Not (alls = 0) Then
lv = Int(tts * 100000 / alls) / 1000
MsgBox(Str(lv) "%", , "正确率")
tx.Visible = False
ty.Visible = False
tz.Visible = False
ok.Visible = False
l1.Visible = False
l2.Visible = False
l3.Visible = False
Else
MsgBox("答题!", , "答题!")
End If
End Sub
End Class
软糖
来回答罗。
“调用事件”有歧义,你的意思是不是下面两种:
调用事件处理方法
直接调用对象名.方法名
'例如有这样一个按钮点击事件处理程序
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
秒表.Start()
End Sub
'调用它直接用
Button1_Click(me, new EventArgs())引发事件
Button1.Click.Invoke(me, new EventArgs())另外 RaiseEvent
也可以引发事件,但不能使用
RaiseEvent 来引发派生窗体的控件事件,只有自己定义的类的事件才能用它引发。
如满意,请采纳,谢谢。
TextBox1_GotFocus(sender,e)
如果调用的那个方法不是
(ByVal sender As Object, ByVal e As System.EventArgs)
这个签名的话,用TextBox1_GotFocus(Nothing, Nothing)也行,但是不太好。
你可以在vb.net里将你需要的空间做成控件并生成ocx控件或生成dll控件库,再到vb6里调用就成了。
与使用System.Windows.Forms命名空间中的控件的用法没有区别。
首先添加引用。
其次导入(Imports)命名空间。
接着就可以使用了:
1、要使用用户控件的实例成员,就先创建一个用户控件的实例,再通过实例名.实例成员名访问;
2、要使用用户控件的共享(Shared)成员,通过用户控件类名.共享成员名访问。
如果你问的是怎样创建自己的用户控件类:
1、继承类System.Windows.Forms.UserControl;
2、继承任何一个已经存在的控件类(只要这个控件类不是NotInheritable的就行)。
VB.net语言
1、创建组件定义
新建一个Probject,在代码中写入:
Public Interface IDemo
Function Test() As String
End Interface
2、实现组件定义
新建一个Probject,添加对上述Probject的引用后,在代码中写入
Public Class Demo
Implements IDemo.IDemo
Public Function Test() As String Implements IDemo.IDemo.Test
Test = "Hello World!"
End Function
End Class
3、编译出Demo.dll组件
4、使用.net的工具 Visual Studio .Net 2003 Command Prompt,输入以下命令
Regasm Demo.dll /tlb:Demo.tlb
把Demo.dll注册为一个com对象(这个com对象不等同于普通的用VB编写的Com对象),并导出类型库Demo.tlb
5、新建一个VB工程,添加对Demo.tlb和IDemo.tlb的引用
6、定义两个全局变量
Dim vbDemo As Demo.Demo
Dim vbIDemo as IDemo.IDemo
7、在Form_Load事件中初始化
'初始化实体类
Set vbDemo = New Demo.Demo
'将实体类引用到抽象类
Set vbIDemo = vbDemo
8、然后,我们就可以用 vbIDemo.Test 这样的方法了