vb.net实现桌面弹球的简单介绍
vb.net的弹出式菜单怎么做
工具箱里有ContextMenu(.NET2.0以后名字有点变化,大概差不多),你加入窗体后就可以像编辑普通菜单那样编辑。
创新互联主要从事成都网站制作、网站设计、网页设计、企业做网站、公司建网站等业务。立足成都服务天祝藏族自治,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:13518219792
编辑好后,选中你要添加菜单的控件。属性窗口里有个ContextMenu属性,在里面选你刚才建立的ContextMenu
求大神用VB编写一个随机弹球。。急急急。。。。
'一个timer1控件,一个picture1控件,在picture1控件中再加入一个shape1控件。单击picture1控件可以暂停或继续
Option Explicit
Const offset = 200
Dim flag As Boolean, u, r
Private Sub Form_Load()
With Timer1
.Enabled = False
.Interval = 30
End With
Randomize
u = Int(Rnd * 2): r = Int(Rnd * 2)
End Sub
Private Sub Form_Resize()
With Picture1
.Top = 10
.Left = 10
.Height = Me.ScaleHeight - 2 * .Top
.Width = Me.ScaleWidth - 2 * .Left
End With
With Shape1
.Width = Picture1.Width / 20
.Left = (Picture1.Width - .Width) / 2
.Top = (Picture1.Height - .Height) / 2
.Shape = 3
.FillStyle = 0
.FillColor = vbRed
End With
End Sub
Private Sub Picture1_Click()
flag = Not flag
If flag Then Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If Not flag Then
Timer1.Enabled = False
Exit Sub
End If
With Shape1
If r = 1 And u = 1 Then '右上
.Left = .Left + offset
If .Left + .Width = Picture1.Width Then
.Left = Picture1.Width - .Width
r = 0
End If
.Top = .Top - offset
If .Top = 0 Then
.Top = 0
u = 0
End If
End If
If r = 1 And u = 0 Then '右下
.Left = .Left + offset
If .Left + .Width = Picture1.Width Then
.Left = Picture1.Width - .Width
r = 0
End If
.Top = .Top + offset
If .Top + .Height = Picture1.Height Then
.Top = Picture1.Height - .Height
u = 1
End If
End If
If r = 0 And u = 1 Then '左上
.Left = .Left - offset
If .Left = 0 Then
.Left = 0
r = 1
End If
.Top = .Top - offset
If .Top = 0 Then
.Top = 0
u = 0
End If
End If
If r = 0 And u = 0 Then '左下
.Left = .Left - offset
If .Left = 0 Then
.Left = 0
r = 1
End If
.Top = .Top + offset
If .Top + .Height = Picture1.Height Then
.Top = Picture1.Height - .Height
u = 1
End If
End If
End With
End Sub
VB.net怎么弹出如下类似的对话框(看图)?
可以利用msgbox 实现,也可以通过另外的窗体上画出表格实现
方法一,利用msgbox:
Private Sub Command1_Click()Dim a As Long, b As Long, c As LongMsgBox "┌────┬────┬────┐" vbCrLf _ "│ 库存1 │ 库存2 │ 库存3 │" vbCrLf _ "├────┼────┼────┤" vbCrLf _ "│" formatstr(a) "│" formatstr(b) "│" formatstr(c) "│" vbCrLf _ "└────┴────┴────┘" End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j) inputStr Space(j) Space((8 - Len(inputStr)) Mod 2)End Function
方法二,利用窗体实现:
’新建form2窗体‘将以下代码复制到form2窗体中Private Sub Form_Load()ShowPrint "┌────┬────┬────┐" vbCrLf _ "│ 库存1 │ 库存2 │ 库存3 │" vbCrLf _ "├────┼────┼────┤" vbCrLf _ "│" formatstr(a) "│" formatstr(b) "│" formatstr(c) "│" vbCrLf _ "└────┴────┴────┘" End SubPrivate Function formatstr(ByVal inputStr As String) As StringDim j As Integerj = (8 - Len(inputStr)) \ 2formatstr = Space(j) inputStr Space(j) Space((8 - Len(inputStr)) Mod 2)End Function‘将以下代码复制在form1窗体中Private Sub Command1_Click()Form2.ShowEnd Sub
VB.NET如何让弹出的窗体显示在所有的窗体的最前面(包括其他程序打开的窗体)
你可以这样做,设置窗体的TopMost 属性为真!
Me.TopMost = True
Form.TopMost 属性
获取或设置一个值,指示该窗体是否应显示为最顶层窗体。
标题名称:vb.net实现桌面弹球的简单介绍
当前地址:http://hbruida.cn/article/ddohise.html