Public Class ks
為昌江等地區(qū)用戶提供了全套網(wǎng)頁設(shè)計制作服務(wù),及昌江網(wǎng)站建設(shè)行業(yè)解決方案。主營業(yè)務(wù)為做網(wǎng)站、成都網(wǎng)站制作、昌江網(wǎng)站設(shè)計,以傳統(tǒng)方式定制建設(shè)網(wǎng)站,并提供域名空間備案等一條龍服務(wù),秉承以專業(yè)、用心的態(tài)度為用戶提供真誠的服務(wù)。我們深信只要達到每一位用戶的要求,就會得到認(rèn)可,從而選擇與我們長期合作。這樣,我們也可以走得更遠(yuǎn)!
Inherits System.Windows.Forms.Form
#Region " Windows 窗體設(shè)計器生成的代碼 "
Public Sub New()
MyBase.New()
'該調(diào)用是 Windows 窗體設(shè)計器所必需的。
InitializeComponent()
'在 InitializeComponent() 調(diào)用之后添加任何初始化
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 窗體設(shè)計器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下過程是 Windows 窗體設(shè)計器所必需的
'可以使用 Windows 窗體設(shè)計器修改此過程。
'不要使用代碼編輯器修改它。
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
軟糖
來回答羅。
“調(diào)用事件”有歧義,你的意思是不是下面兩種:
調(diào)用事件處理方法
直接調(diào)用對象名.方法名
'例如有這樣一個按鈕點擊事件處理程序
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
秒表.Start()
End Sub
'調(diào)用它直接用
Button1_Click(me, new EventArgs())引發(fā)事件
Button1.Click.Invoke(me, new EventArgs())另外 RaiseEvent
也可以引發(fā)事件,但不能使用
RaiseEvent 來引發(fā)派生窗體的控件事件,只有自己定義的類的事件才能用它引發(fā)。
如滿意,請采納,謝謝。
TextBox1_GotFocus(sender,e)
如果調(diào)用的那個方法不是
(ByVal sender As Object, ByVal e As System.EventArgs)
這個簽名的話,用TextBox1_GotFocus(Nothing, Nothing)也行,但是不太好。
你可以在vb.net里將你需要的空間做成控件并生成ocx控件或生成dll控件庫,再到vb6里調(diào)用就成了。
與使用System.Windows.Forms命名空間中的控件的用法沒有區(qū)別。
首先添加引用。
其次導(dǎo)入(Imports)命名空間。
接著就可以使用了:
1、要使用用戶控件的實例成員,就先創(chuàng)建一個用戶控件的實例,再通過實例名.實例成員名訪問;
2、要使用用戶控件的共享(Shared)成員,通過用戶控件類名.共享成員名訪問。
如果你問的是怎樣創(chuàng)建自己的用戶控件類:
1、繼承類System.Windows.Forms.UserControl;
2、繼承任何一個已經(jīng)存在的控件類(只要這個控件類不是NotInheritable的就行)。
VB.net語言
1、創(chuàng)建組件定義
新建一個Probject,在代碼中寫入:
Public Interface IDemo
Function Test() As String
End Interface
2、實現(xiàn)組件定義
新建一個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對象),并導(dǎo)出類型庫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 這樣的方法了