资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net两窗体调用,vba窗体

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(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

VB.net 怎么实现多项目之间的窗体调用?

首先引入那个项目的命名空间,在代码最上方用Imports语句,比如

Imports Project1

然后在需要用的地方写

Dim aform As New MyForm1()

然后通过aform对象的Show方法(弹出普通窗口)或ShowDialog(弹出窗口时后方窗口无响应)方法来显示窗口,最后调用Dispose方法释放对象内存。

VB.net 两个窗体之间传递参数

新窗体中写

构造函数

,然后调用。

比如你要调用的新窗体是From1.cs这个窗体,

public

Form1(要传入的参数)

{

//把传入的参数传入窗体中

//执行窗体标准内容

}

然后在需要调用的地方调用

Form1

f

=

new

Form1(传出的参数);

'--------Form1--------

Dim

f2

As

Form2

Private

Sub

Command1_Click()

Set

f2

=

New

Form2

f2.Show

vbModal

End

Sub

'--------Form1

End--------

'--------Form2--------

Dim

WithEvents

f3

As

Form3

Private

Sub

Command1_Click()

Set

f3

=

New

Form3

f3.Show

End

Sub

Public

Sub

f3_f2W()

Me.Command1.Caption

=

"f2W"

End

Sub

'--------Form2

End--------

'--------Form3--------

Public

Event

f2W()

Private

Sub

Command1_Click()

RaiseEvent

f2W

End

Sub

'--------Form3

End--------

f.Show();

如此就能实现调用了。

VB.NET两个窗体怎么同步显示或隐藏?

1、没有事件是直接由最小化、还原触发的,它们都会触发SizeChanged事件。所以你可以写主窗体的SizeChanged事件来控制副窗体显隐,顺便改变副窗体的相对位置;

2、在SizeChanged事件中,通过判断窗体的WindowState属性来确定用户是最小化还是还原了;(FormWindowState.Minimized和FormWindowState.Normal枚举)

3、调用副窗体的BringToFront方法可以把副窗体带到最前面来

vb.net 如何在一个窗体中调用另一个窗体的load事件

很简单啊,在按钮的点击事件中调用窗体的show()方法就好了

button.onclick(){

frame1.show();

}


文章标题:vb.net两窗体调用,vba窗体
URL网址:http://cdkjz.cn/article/hscjjp.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220