vb.net如何调用窗体之间的控件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(130 * Rnd())
y = Int(120 * Rnd())
z = Int(125 * Rnd())
a = Int(24 * Rnd())
b = Int(1a * 2 * Rnd())
c = Int(1b * 2 * Rnd())
d = Int(1c * 3 * Rnd())
aa = xyz
bb = a * xb * yc * z
cc = b * xc * yd * 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 = tts1
End If
alls = alls1
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(24 * Rnd())
b = Int(1a * 2 * Rnd())
c = Int(1b * 2 * Rnd())
d = Int(1c * 3 * Rnd())
aa = xyz
bb = a * xb * yc * z
cc = b * xc * yd * 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
vb.net mdiform的父窗口调用子窗口的函数既然子窗体都有同名函数,就应该对子窗体进行一层封装,子类实现不同方法
Public MustInherit Class AbstractChild
Public MustOverride Sub Method1()
End Class
Public Class ChildClass1
Inherits AbstractChild
Public Overrides Sub Method1()
MessageBox.Show("class1")
End Sub
End Class
Public Class ChildClass2
Inherits AbstractChild
Public Overrides Sub Method1()
MessageBox.Show("class2")
End Sub
End Class
Public Class ChildClass3
Inherits AbstractChild
Public Overrides Sub Method1()
MessageBox.Show("class3")
End Sub
End Class
Dim child1 As New ChildClass1()
Dim child2 As New ChildClass2()
Dim child3 As New ChildClass3()
child1.Method1()
child2.Method1()
child3.Method1()
vb.net 获取子窗口的变量值用CType转成vb.net调用子窗口你vb.net调用子窗口的窗口类型就可以引用了
比如你vb.net调用子窗口的子窗口类是MyForm
单击父窗口Button2显示它包含字符串MyPath的内容的代码如下
Private Sub Button2_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
MsgBox(CType(Me.ActiveMdiChild, MyForm).MyPath)
End Sub
VB.net 怎么实现多项目之间的窗体调用?首先引入那个项目vb.net调用子窗口的命名空间vb.net调用子窗口,在代码最上方用Imports语句vb.net调用子窗口,比如
Imports Project1
然后在需要用vb.net调用子窗口的地方写
Dim aform As New MyForm1()
然后通过aform对象vb.net调用子窗口的Show方法(弹出普通窗口)或ShowDialog(弹出窗口时后方窗口无响应)方法来显示窗口,最后调用Dispose方法释放对象内存 。
如何给VB.NET窗体添加子窗体?直接添加一个MID父窗体或在已有窗体的属性中找到IsMDIContainer属性,然后设置为True,然后创建第二个窗体 ,需要加载子窗体的时候:
Dim NewMDIChild As New Form2
NewMDIChild.MdiParent = Me
NewMDIChild.Show()
Public Shared Sub CheckMDIChildForm(ByVal MDIForm As Windows.Forms.Form, ByVal MDIChildForm As Windows.Forms.Form, ByVal MDIChildFormName As String)
If MDIForm.MdiChildren.Length1 Then
'如果没有任何一个MDI子窗体,则创该MDI子窗体的窗体实例
Dim MDIChildFrm As Windows.Forms.Form = MDIChildForm ' 定义MDI子窗体
MDIChildFrm.MdiParent = MDIForm '指定父窗体
MDIChildFrm.Show() '打开窗体
Exit Sub
Else
Dim x As Integer
Dim frmyn As Boolean
For x = 0 To (MDIForm.MdiChildren.Length) - 1
Dim tempChild As Windows.Forms.Form = CType(MDIForm.MdiChildren(x), Windows.Forms.Form)
If tempChild.Name = MDIChildFormName Then
'检测到有该MDI子窗体 , 设为激活 并退出循环
frmyn = True
tempChild.BringToFront()
Exit For
Else
frmyn = False
End If
Next
If Not frmyn Then
'在打开的窗体中没检测到则新建
Dim MDIChildFrm As Windows.Forms.Form = MDIChildForm ' 定义MDI子窗体
MDIChildFrm.MdiParent = MDIForm '指定父窗体
MDIChildFrm.Show() '打开窗体
End If
End If
End Sub
【vb.net调用子窗口 vb调用子程序】关于vb.net调用子窗口和vb调用子程序的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息 , 记得收藏关注本站 。
推荐阅读
- 物理机迁移虚拟机,物理机迁移虚拟机后蓝屏
- 手机怎么样拍电影和电视,手机如何拍电视
- php把数据表格,php中表格如何设置
- 宝马车插u盘怎么查文件夹,宝马汽车如何读取u盘
- 怎么打开本地mysql 怎么打开本地相册
- 关于css中高度包含边框和内边距的信息
- html5波浪,css中的波浪线样式
- 带货直播数据平台,带货直播数据平台哪个好
- vb.net组件开发 vbnet ide