當前位置:首頁 » 編程軟體 » 編程vb實例

編程vb實例

發布時間: 2024-03-22 22:49:45

㈠ VB.NET 拖動無邊框窗體編程實例

Imports System Drawing Imports System Windows Forms 裂搭手 ****************************************** Private oOriginalRegion As Region = Nothing 用於窗體移動 Private bFormDragging As Boolean = False Private oPointClicked As Point ****************************************** Private Sub Form _MouseDown(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles MyBase MouseDown Me bFormDragging = True Me oPointClicked = New Point(e X e Y) End Sub ****************************************** Private Sub Form _MouseUp(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles MyBase MouseUp Me bFormDragging = False End Sub ****************************************** Private Sub Form _MouseMove(ByVal sender As Object ByVal e As System Windows Forms MouseEventArgs) Handles MyBase MouseMove If Me bFormDragging Then Dim oMoveToPoint As Point 以當前滑鼠肆嫌位置為基礎 找出目標位置 oMoveToPoint = Me PointToScreen(New Point(e X e Y)) 枝兄 根據開始位置作出調整 oMoveToPoint Offset(Me oPointClicked X * _ (Me oPointClicked Y + _ SystemInformation CaptionHeight + _ SystemInformation BorderSize Height) * ) 移動窗體 Me Location = oMoveToPoint End If

lishixin/Article/program/ASP/201311/21755

㈡ vb編程例題

PrivateSubCommand1_Click()
Dima(10)AsInteger,xAsInteger
Randomize
Fori=1To10
a(i)=Int(Rnd()*51)
Printa(i);
Nexti
Print
x=InputBox("請輸入一個數:")
Fori=1To10
Ifa(i)=xThenExitFor
Nexti
Ifi<11Then
Print"a(";i;")=";x
Else
Print"未找到";x
EndIf
EndSub

㈢ 求一個簡單vb編程實例~

控制項:image,picture,timer代碼:Dim x As Integer
Dim y As IntegerPrivate Sub Form_Load()
x = 100
y = 100
Timer1.Interval = 100
End SubPrivate Sub Timer1_Timer()
If img.Top >= pic.Height - img.Height Then
y = -100
End If
If img.Top <= 0 Then
y = 100
End If
If img.Left >= pic.Width - img.Width Then
x = -100
End If
If img.Left <= 0 Then
x = 100
End If
img.Top = img.Top + y
img.Left = img.Left + x
End Sub
以上代碼實現的是圖片框中的一個小球做的規律的運動,當小球碰到圖片框邊緣時便反彈繼續運動

熱點內容
蘋果手機如何往安卓手機導通訊錄 發布:2025-07-04 10:19:11 瀏覽:131
未來之役如何換伺服器 發布:2025-07-04 10:13:51 瀏覽:215
curlc上傳 發布:2025-07-04 09:59:35 瀏覽:881
沒有編譯器能運行c程序嗎 發布:2025-07-04 09:54:38 瀏覽:308
創建配置目錄錯誤是什麼意思 發布:2025-07-04 09:53:35 瀏覽:49
為什麼租憑伺服器不能玩了 發布:2025-07-04 09:03:01 瀏覽:984
安卓手機減肥軟體哪個好 發布:2025-07-04 08:51:17 瀏覽:997
Oracle查看資料庫歸檔 發布:2025-07-04 08:44:53 瀏覽:608
950買什麼配置好 發布:2025-07-04 08:39:39 瀏覽:611
怎樣給應用加密 發布:2025-07-04 08:38:41 瀏覽:458