Presentation is loading. Please wait.

Presentation is loading. Please wait.

程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷

Similar presentations


Presentation on theme: "程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷"— Presentation transcript:

1 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷 E-mail : tsuiting@scu.edu.tw tsuiting@scu.edu.tw

2 調色盤

3 捲軸( scroll Bar ) 輸入數值 限制範圍 垂直捲軸( Vertical Scroll Bar ) vsb 水平捲軸( Horizontal Scroll Bar ) hsb 微動鈕 快捲區 捲動鈕

4 屬性 –LargeChange 快捲區 –Max ( -32768 ~ 32767 ) –Min ( -32768 ~ 32767 ) –SmallChange 微動鈕 –Value 捲軸( scroll Bar )

5 事件 –Scroll 移動捲動鈕時觸動 –Change 移動微動鈕時觸動。 Value 改變時觸動。 捲軸( scroll Bar )

6 Private Sub hsbBlue_Change() picmix.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value) lblBlue.Caption = " 藍 =" & hsbBlue.Value End Sub Private Sub hsbGreen_Change() picmix.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value) lblGreen.Caption = " 綠 =" & hsbGreen.Value End Sub Private Sub hsbRed_Change() picmix.BackColor = RGB(hsbRed.Value, hsbGreen.Value, hsbBlue.Value) lblRed.Caption = " 紅 =" & hsbRed.Value End Sub

7 滑鼠事件 MouseDown MouseUp MouseMove Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) End Sub

8 Private Sub Form_Load() picTrashFull.Visible = False picPlane.DragIcon = picPlane.Picture picShuttle.DragIcon = picShuttle.Picture picBicycle.DragIcon = picBicycle.Picture End Sub Private Sub picTrashEmpty_DragDrop(Source As Control, X As Single, Y As Single) picTrashFull.Visible = True Source.Visible = False End Sub Private Sub picTrashFull_DragDrop(Source As Control, X As Single, Y As Single) picTrashFull.Visible = True Source.Visible = False End Sub

9 再談屬性 DragMode : –0( 預設值 ) Manual - 需要在來源控制項中用 Drag 方法來啟動拖放動作。 –1 Automatic - 按一下來源控制項就自動引發拖 放動作。 DragIcon :設定拖曳時之圖示

10 再談屬性 DragMode : –0( 預設值 ) Manual - 需要在來源控制項中用 Drag 方法來啟動拖放動作。 –1Automatic - 按一下來源控制項就自動引發拖放 動作。 Drag 方法:須配合 DragMode 設為 0 – 【物件名】.Drag ( action ) vbCancel0 vbBeginDrag1 vbEndDrag2

11

12

13 Button 引數 00000 中鍵右鍵左鍵 Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) Select Case Button Case 1: Print " 你按了滑鼠左鍵 " Case 2: Print " 你按了滑鼠右鍵 " Case 4: Print " 你按了滑鼠中鍵 " End Select End Sub

14 Shift 引數 00000Alt 鍵 Ctrl 鍵 Shift 鍵 If (Button = 1) And (Shift = 1) Then picEarth.Visible = True picEarth.Move X, Y End If 新 增一移動圖片之功能於選單 當 按下該選項,圖片出現 當 在表單上同時按下 Shift + 左 鼠鍵時, 移動該圖片到該位置

15 繪圖程式碼 Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) DrawIt = True frmPainter.CurrentX = X ' 紀錄開始畫圖之起點 X 座標 frmPainter.CurrentY = Y ' 紀錄開始畫圖之起點 Y 座標 End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If DrawIt Then Line -(X, Y) End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) DrawIt = False ' 停止繪製 End Sub

16 DragDrop 事件 – 當將來源物件( Source )拖曳至目的物件 ( Target )上,則目的物件就會收到 DragDrop 事件並執行在目的物件( Target ) DragDrop 事件程序中定義之動作。 Private Sub picTrashEmpty_DragDrop(Source As Control, X As Single, Y As Single) End Sub

17 再談屬性 ToolTip Text :滑鼠停在控制項上時, 要顯示的提示文字。 Tag :儲存程式中所需之額外資料。

18

19

20

21 Form 屬性 DrawWidth 屬性:用來指定圖形方法 輸出時直線的寬度。 BorderWidth 屬性:則是用來指定直線 和幾何圖形控制項框線的粗細。

22 X,Y 引數 傳回滑鼠指標所在之座標 Form 屬性: CurrentX 、 CurrentY Line :畫出兩個座標點之間的直線 [object.] Line [(x1, y1)]-(x2, y2)[, color] Line (500,500)-(2000,2000) Line – (400,400)  Line (0,0) – (400,400) Line – (X,Y)  Line (CurrentX,CurrentY) – (X,Y)

23 設計小畫家 以拖曳滑鼠繪圖 1.Mouse_Down 設 定可畫圖 設 定繪圖起點座標 ( CurrentX,CurrentY ) 2.Mouse_Up 設 定不可畫圖 3.Mouse_Move 若 可畫圖 則繪製 ( CurrentX,CurrentY )到 (X,Y) 之線段

24 期末考 6 月 23 日 下午 1:35 – 3:05 上機考 OpenBook 請攜帶磁片,以防當機;或存於自己的 W 槽


Download ppt "程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0 程式設計 Visual Basic 6.0 Visual Basic 6.0 Visual Basic 6.0許翠婷"

Similar presentations


Ads by Google