VB ActiveX ¨Ï¥Î¤èªk(¤@)

¦^­º­¶


¤ÀÃþ

¼ÐÃD

¤j·N

§@ªÌ

¤é´Á

MSFLXGRD ¦b MsFlexGrid ùØ¿é¤J¸ê®Æ Col & Row ¦Ñ©Ç 1998/7/15
MSFLXGRD ¦b MsFlexGrid Sort ¡@ ¦Ñ©Ç 1998/8/13
MSFLXGRD ¨ú¥X MsFlexGrid ªº­È ¡@ ¦Ñ©Ç 1998/8/18
MSCHART ¨Ï¥Î MsChart ø¹Ï ¡@ ¦Ñ©Ç 1998/7/15
CRYSTL32 ¥Î CrystalReport ¦L³øªí RPT Àɦb VB ùتº¹B¥Î ¦Ñ©Ç 1998/7/16
MSWINSOCK SendData ªº®É¾÷ WinSock.State ÄÝ©Ê ¦Ñ©Ç 1998/8/2
MSWINSOCK ¶Ç°e¤G¶i¦ì¸ê®Æ ¡@ ¦Ñ©Ç 1998/9/6
ToolBar ¦b MdiForm ùرҰʤlªí³æ Button ª«¥óªº¨Ï¥Î ¦Ñ©Ç 1998/8/14
ToolBar ´¡¤J«ö¯Ã¹Ï¥Ü ·f°t ImageList ªº¹B¥Î ¦Ñ©Ç 1998/11/26
MaskEdit ¦p¦ó¦b MaskEdit ùØ¿é¤J¤¤¤å¦r¤¸ ¾B¸n¦r¤¸ "C" ¦Ñ©Ç 1998/8/14
RichTextBox ¥Îµ{¦¡±Ô­zÅÜ´«¦rÅé ¡@ ¦Ñ©Ç 1998/8/29
RichTextBox HyPerLink ¼ÒÀÀ ¡@ ¦Ñ©Ç 1998/8/30
RichTextBox ¦bRTFÀɤ¤·j´M¬Y¤@­Ó¦r¦ê RichTextBox.LoadFile ¦Ñ©Ç 1998/9/22
ProgressBar ProgressBar °ò¥»¹B§@¼Ò«¬ ¡@ ¦Ñ©Ç 1998/9/15
SSTab ¦p¦ó¦b SSTab ¤¤¤Á´«­¶ÅÒ ¡@ ¦Ñ©Ç 1998/9/26
MCIControl ­I´º´`Àô¼½©ñ Wave ÀÉ ¡@ ¦Ñ©Ç 1998/10/14
TreeView Node ª«¥óªº±²°Ê ¡@ ¦Ñ©Ç 1998/12/9
TreeView Nodes.Add ¤èªk°Ñ¼Æ¸Ô¸Ñ ¡@ ¦Ñ©Ç 1998/12/9
¦Û»s¤¸¥ó ¦p¦óÅý¤¸¥ó°õ¦æ´Á¤£¥i¨£ UserControl.InvisibleAtRuntime ¦Ñ©Ç 1998/8/12
¦Û»s¤¸¥ó ActiveX ¨Æ¥óªº²£¥Í Event & RaiseEvent ¦Ñ©Ç 1998/9/24

¦b MsFlexGrid ùØ¿é¤J¸ê®Æ


¬PÇUª÷³f ¼¶¼g©ó¤å³¹

Microsoft FlexGrid Control 5.0 ³o­Ó Ocx ±N¥L«Ø¥ß¥X¨Ó¤§«á¤£ª¾¹D­n¦p¦ó±±¨î¤~¯à¿é¤J¸ê®Æ

¦Ñ©Çµª¡G

  1. ³]©wÄæ¼Æ¤Î¦C¼Æ
  2. «ü©w§@¥Î¤¤ªº Celll¡G
  3. ³]©w¥Ø«e°Ê§@ Cell ªº¤å¦r¡G
  4. ¸ü¤J¹Ï¤ù

¦^¯Á¤Þ


¨Ï¥Î MsChart ø¹Ï


hahaha ¼¶¼g©ó¤å³¹

¥s¤Fgraphª«¥ó¨Óµe¼Æ­È¹Ï¡A¦ý¤£ª¾¦p¦ó±N¼Æ­Èshow¥X¨Ó¡A·Ð½Ð¦U¦ì«e½ú¸Ñµª¡AÁÂÁ¡I

¦Ñ©Çµª¡G

½Ð°Ñ¦Ò¤U¨Ò¡G

Dim varStyle(11) As Integer
Private Sub Command1_Click()
Static Style As Integer
    If Style > 11 Then Style = 0

    MSChart1.chartType = varStyle(Style)

    Style = Style + 1
End Sub

Private Sub Form_Load()
Dim MyData(4, 1) As Single
    varStyle(0) = VtChChartType2dArea
    varStyle(1) = VtChChartType2dBar
    varStyle(2) = VtChChartType2dCombination
    varStyle(3) = VtChChartType2dLine
    varStyle(4) = VtChChartType2dPie
    varStyle(5) = VtChChartType2dStep
    varStyle(6) = VtChChartType2dXY
    varStyle(7) = VtChChartType3dArea
    varStyle(8) = VtChChartType3dBar
    varStyle(9) = VtChChartType3dCombination
    varStyle(10) = VtChChartType3dLine
    varStyle(11) = VtChChartType3dStep

    MyData(0, 0) = 1
    MyData(0, 1) = 10
    MyData(1, 0) = 2
    MyData(1, 1) = 30
    MyData(2, 0) = 3
    MyData(2, 1) = 20
    MyData(3, 0) = 4
    MyData(3, 1) = 15
    MyData(4, 0) = 5
    MyData(4, 1) = 25

    MSChart1.ChartData = MyData

End Sub

¦^¯Á¤Þ


¥Î CrystalReport ¦L³øªí


¤p°ª ¼¶¼g©ó¤å³¹

¦bvb¤¤¨Ï¥Î³øªí²£¥Í¾¹§@¥X¤F¤@­Ó³øªí¡A­n¦p¦ó±N³o­Ó¦C¦L¥\¯à¥[¤J§Ú³]­pªºµ{¦¡¤¤¡H

¦Ñ©Çµª¡G

CrystalReport1.Destination = crptToPrinter
CrystalReport1.ReportFileName = "§Aªº³øªíÀÉ"
CrystalReport1.Action = 1

¦^¯Á¤Þ


SendData ªº®É¾÷


­³®¦ ¼¶¼g©ó¤å³¹

winsock1.state ¦³®Éµ¥©ó sckConnecting   (6) ¦¹®É©I¥s winsock1.senddata ·|¿ù»~¡Awinsock1.dtate ¦³®Éµ¥©ó sckConnected    (7) ¦¹®É©I¥s winsock1.senddata ¦¨¥\¤£ª¾¬O¦ó­ì¦]?

¦Ñ©Çµª¡G

  1. WinSock.State=sckConnecting ªí¥Ü¥¿¦b³s½u¡A³sªº¦¨³s¤£¦¨³£ÁÙ¤£ª¾¹D¡A«ç»òSenddata ©O¡H
  2. WinSock.State=sckConnected ¬O§¹¦¨¦¡¡Aªí¥Ü³s½u¦¨¥\¤F¡A·íµM´N¥i¥H SendData ¤F¡A©Ò¥H¦b SendData ¤§«e¡AÁÙ¬O¥ý Check WinSock.State ª¬ºA¤ñ¸û¦n¡C
  3. §A¤]¥i±Ä³o¼Ëªº±Ô­z¡G
    Private Sub Command1_Click()
        Winsock1.Connect
    End Sub

    Private Sub Winsock1_Connect()
        Winsock1.SendData "YourData"
    End Sub
    ¦]¬°Winsock1_Connect()¬O Connect §¹¦¨«á²£¥Íªº³qª¾¨Æ¥ó¡A¦b³o¸Ì SendData ¡A¥iÁקK¥¼³s½u§¹¦¨§Y SendData¡C

¦^¯Á¤Þ


¦p¦óÅý¤¸¥ó°õ¦æ´Á¤£¥i¨£


°Â¥J ¼¶¼g©ó¤å³¹

½Ð°Ý§Ú·Q¨ú®ø¤@­Ó¦Û¤v°µªºcontrolªºheight ©Mwidth ÄÝ©ÊÀ³¸Ó«ç¼Ë°µ??´N¦ptimercontrol ¤@¼Ë¤£¯à±±¨îsize,¨S¦³ height ©Mwidth ÄÝ©Ê¥i¿ï¾Ü!!

¦Ñ©Çµª¡G

UserControl.InvisibleAtRuntime=True

¤£¹L³o´N©M timer ¤@¼Ë¡A°õ¦æ®É´Á¤£¥i¨£¤F¡A©Ò¥H°õ¦æ®É´Á¥i¨£ªº Control ¡A¤@©w·|¦³ left,top,width,height ªºÄÝ©Ê¡C

¦^¯Á¤Þ


¦b MsFlexGrid Sort


±m­i¨T¤ô+¥i¼Ö®R®ðªw ¼¶¼g©ó¤å³¹

½Ð°Ý¦p¦óÅý MFSGric ¤¤ªº¸ê®Æ·Ó¦r¥À¥ý«á§Ç±Æ¦C?¬O¤£¬O¦³¤°»òÄÝ©Ê¥i¥H¥Î¨Óª½±µ±±¨î³o­Ó©Ê½è?

¦Ñ©Çµª¡G

MSFlexGrid ¦³¤@­Ó¥s Sort ªºÄÝ©Ê¡A¬O°õ¦æ¶¥¬q¤~¯à¨Ï¥ÎªºÄÝ©Ê¡AMSFlexGrid ªþ¦³§¹¾ãªº»¡©ú©M½d¨Ò¡A¤£½×¬O¦b Help ùØ¡A©Î¬OÂsÄýµøµ¡ùØ¡A³£¥i¥H¥sªº¨ì¡A§A¥h§ä§ä¡C½d¨Ò¦p¤U¡G

Private Sub Command1_Click()
FG.Col = 0
FG.Sort = 7
End Sub

Private Sub Command2_Click()
FG.Col = 1
FG.Sort = 7
End Sub


Private Sub Command3_Click()
FG.Col = 2
FG.Sort = 7
End Sub

Private Sub Form_Load()
FG.Cols = 3
FG.AddItem "A" & Chr(9) & "04" & Chr(9) & "Z"
FG.AddItem "B" & Chr(9) & "08" & Chr(9) & "Y"
FG.AddItem "C" & Chr(9) & "02" & Chr(9) & "X"
FG.AddItem "D" & Chr(9) & "09" & Chr(9) & "W"
FG.AddItem "E" & Chr(9) & "03" & Chr(9) & "U"

Command1.Caption = "Sort 1"
Command2.Caption = "Sort 2"
Command3.Caption = "Sort 3"
End Sub

¥»¨Ò MSFlexGrid.Name=FG

¦^¯Á¤Þ


¨ú¥X MsFlexGrid ªº­È


¡@

Smith ¼¶¼g©ó¤å³¹

·í§Ú§â¸ê®Æ¤@¤@­Ë¤JMSFlexGrid¤¤¥H«á¨º§Ú«á¨Ó¬O§_¦³¿ìªk±N¨ä¤¤¤@­ÓÄæ¦ìªº¸ê®Æ¦A§ì¥X¨Ó©O?

¦Ñ©Çµª¡G

½Ð§A¦b Form ¤W¥¬¸m Text1,Text2,MsflexGrid «á°õ¦æ¤U¦C¦¡¤l¡G

Option Explicit
Private Sub Form_Load()
Dim I As Integer

    MSFlexGrid1.Cols = 3
    MSFlexGrid1.Rows = 10
    '¨Ï¥Î TextArray ÄÝ©Ê¡A¥Î¸ê®Æ¨Ó¶ñº¡ MSFlexGrid¡C
    For I = MSFlexGrid1.FixedRows To MSFlexGrid1.Rows - 1
        '** ¸ê®Æ¦æ 1
        MSFlexGrid1.TextArray(faIndex(I, 1)) = I & "\ 1"
        '¸ê®Æ¦æ 2.
        MSFlexGrid1.TextArray(faIndex(I, 2)) = I & "\ 2"
    Next
End Sub

Private Sub MSFlexGrid1_EnterCell()
Dim CellX As Long
Dim CellY As Long

    CellX = MSFlexGrid1.row
    CellY = MSFlexGrid1.col
    '§Q¥Î TextMatrix
    Text2.Text = MSFlexGrid1.TextMatrix(CellX, CellY)

    '§Q¥Î«ü©w Cell
    MSFlexGrid1.col = CellY
    MSFlexGrid1.row = CellX
    Text1.Text = MSFlexGrid1.Text
End Sub

'­pºâ¸ò TextArray Äݩʤ@°_¨Ï¥Îªº¯Á¤Þ¡C
Function faIndex(row As Integer, col As Integer) As Long
     faIndex = row * MSFlexGrid1.Cols + col
End Function

¦pªG­n¥Î Data ¶µ¡A§â Form_Load ±Ô­z®³±¼§Y¥i

¦^¯Á¤Þ


¦b MdiForm ùرҰʤlªí³æ


¤pµi»ï ¼¶¼g©ó¤å³¹

½Ð°Ý¤@¤U¦bMDIForm¤¤¨Ï¥Î¤FToolBar Control,¨º·í¦bToolBar¤W«ö¤U«ö¶s«á,¦p¦ó§â±±¨îÅv¥æµ¹¦¹®É¤w¸g¶}±ÒªºChildForm©O?

¦Ñ©Çµª¡G

Option Explicit

Dim Form2 As New Form1
Dim Form3 As New Form1

Private Sub MDIForm_Load()
Dim MyBS As Buttons
    Form2.Caption = "Form2"
    Form3.Caption = "Form3"

    Form2.Show
    Form3.Show

    Set MyBS = Toolbar1.Buttons
    MyBS.Add , "Form1", "±Ò°Êªí¤@"
    MyBS.Add , "Form2", "±Ò°Êªí¤G"
    MyBS.Add , "Form3", "±Ò°Êªí¤T"
End Sub

Private Sub Toolbar1_ButtonClick(ByVal Button As ComctlLib.Button)
    Select Case Button.Key
        Case "Form1"
            Form1.SetFocus
        Case "Form2"
            Form2.SetFocus
        Case "Form3"
            Form3.SetFocus
    End Select
End Sub

¦^¯Á¤Þ


¦p¦ó¦b MaskEdit ùØ¿é¤J¤¤¤å¦r¤¸


¾B¸n¦r¤¸¥Î "C" ¥i¥H¿é¤J¤¤¤å¡A¤£¹L­nª`·Nªº¬O¥¦§â¤¤¤åºâ¨â­Ó¦r¡A©Ò¥H¦pªG¥u³Ñ¤@­Ó¾B¸n¦r¤¸¡A¿é¤J·|¦³¿ù»~¡C

¦^¯Á¤Þ


¥Îµ{¦¡±Ô­zÅÜ´«¦rÅé


²ö©ú©_§®... ªº¤å³¹¤¤´£¨ì:

§Ú·Q°ÝªºÃD¡A¦³¨S¦³¿ìªk¤£ Load ÀɮסA¦Óª½±µ¦bµ{¦¡¤¤¡Aª½±µ¼g¦¨... RichTextBox1.text = ... ³o¼Ëªº®æ¦¡¡A¦Ó¦b¨ä¤¤¡A¥i¥H¦Û¤vÅÜ´«¦rÊ^¡C §Ú¸Õ¹L¡A¦pªG¦b¤¤¶¡§ï¦¨²ÊÊ^¡A¾ã­Ó¤º®e³£·|Åܧó...¦³¨S¦³¿ìªkÅý¨ä¤¤¤@¤p¬qÅÜ°Ê´N¦n¤F©O?

¦Ñ©Çµª¡G

Private Sub Command1_Click()
Dim CR As String
'°O¿ý¿ï¨ú¤§°_©l¦ì¸m
Dim PosStart() As Long
'°O¿ý¿ï¨ú¤§ªø«×
Dim FLength() As Long
    CR = Chr(10)
    RichTextBox1.SelLength = 0
    RichTextBox1.Text = "Hello!" & CR
    RichTextBox1.Text = RichTextBox1.Text & "Hello2!" & CR
    RichTextBox1.Text = RichTextBox1.Text & "¤£­n²z§Ú!" & CR

    ReDim PosStart(0)
    ReDim FLength(0)
    PosStart(0) = 0
    FLength(0) = Len(RichTextBox1.Text)

    RichTextBox1.Text = RichTextBox1.Text & "¤£­n²z§Ú!" & CR
    ReDim Preserve PosStart(1)
    ReDim Preserve FLength(1)
    PosStart(1) = FLength(0)
    FLength(1) = Len(RichTextBox1.Text) - FLength(0)

    RichTextBox1.Text = RichTextBox1.Text & "¤£­n²z§Ú!" & CR
    RichTextBox1.SelStart = PosStart(0)
    RichTextBox1.SelLength = FLength(0)
    RichTextBox1.SelBold = True

    RichTextBox1.SelStart = PosStart(1)
    RichTextBox1.SelLength = FLength(1)
    RichTextBox1.SelItalic = True

    RichTextBox1.SelStart = 0
End Sub

¦^¯Á¤Þ


HyPerLink ¼ÒÀÀ


VERSION 5.00
Object = "{3B7C8863-D78F-101B-B9B5-04021C009402}#1.1#0"; "RICHTX32.OCX"
Begin VB.Form frmMarkUp
   Caption         =   "Hyper MarkUp ¼ÒÀÀ½d¨Ò"
   ClientHeight    =   3480
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5670
   LinkTopic       =   "Form1"
   ScaleHeight     =   3480
   ScaleWidth      =   5670
   StartUpPosition =   3  '¨t²Î¹w³]­È
   Begin RichTextLib.RichTextBox RTBox
      Height          =   3015
      Left            =   240
      TabIndex        =   0
      Top             =   240
      Width           =   5175
      _ExtentX        =   9128
      _ExtentY        =   5318
      _Version        =   327680
      ScrollBars      =   3
      TextRTF         =   $"markup.frx":0000
   End
End
Attribute VB_Name = "frmMarkUp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'¥» Form ¾Þ§@¤è¦¡¬O¦b¤å¦r°Ï¶ô«ö·Æ¹«Áä¡A
'­Y«ö¤@¯ë¦r«hµL¤ÏÀ³¡A­Y«öÂŦâ¥[©³½u¦r¦ê¡A
'«h·|¦³¬Û¹ïÀ³¤§°T®§²£¥Í¡C
Private Type RichHyper
    ¶}©l¦ì¸m As Long
    µ²§ô¦ì¸m As Long
    ³sµ²¦r¦ê As String
End Type
'Àx¦s¼Ð°O¦ì¸m¤Î³sµ²ªº°}¦C
Dim Mark() As RichHyper
Private Sub Form_Load()
Dim PutString As String
Dim I As Integer
    '¥»½d¨Ò¥Î¤F¤T­Ó¼ÐÅÒ
    ReDim Mark(2)

    RTBox.Text = "News Group:tw.bbs.comp.language ¤½§i" + Chr(10)
    RTBox.Text = RTBox.Text + "§Æ±æ¥»ª©ª©¤Í¦b Post °ÝÃD¤§«e¯à¥ý°µ¦n¤U¦C·Ç³Æ
¤u§@¡G" + Chr(10)

    '³]©w¼ÐÅÒ¤@
    RTBox.Text = RTBox.Text + "1."
    '³]©w¼ÐÅÒ¦r¦ê¤Î¦ì¸m
    PutString = "¥ý¬d¸ß VB Help"
    Mark(0).¶}©l¦ì¸m = Len(RTBox.Text)
    Mark(0).µ²§ô¦ì¸m = Len(RTBox.Text) + Len(PutString)
    Mark(0).³sµ²¦r¦ê = "VB Help ¨Ï¥Î»¡©ú"
    RTBox.Text = RTBox.Text + PutString + Chr(10)

    '³]©w¼ÐÅÒ¤G
    RTBox.Text = RTBox.Text + "2."
    PutString = "¬d¾\ VB5 ªì¯Å¥Í¦Ñ©Ç½d¨Ò"
    Mark(1).¶}©l¦ì¸m = Len(RTBox.Text)
    Mark(1).µ²§ô¦ì¸m = Len(RTBox.Text) + Len(PutString)
    Mark(1).³sµ²¦r¦ê = "¦Ñ©Ç½d¨Ò¤U¸ü¿ìªk»¡©ú"
    RTBox.Text = RTBox.Text + PutString + Chr(10)

    '³]©w¼ÐÅÒ¤T
    RTBox.Text = RTBox.Text + "3."
    PutString = "¥J²Ó·Q²M·¡ Post ¤å³¹¥DÃD"
    Mark(2).¶}©l¦ì¸m = Len(RTBox.Text)
    Mark(2).µ²§ô¦ì¸m = Len(RTBox.Text) + Len(PutString)
    Mark(2).³sµ²¦r¦ê = "Post ª`·N¨Æ¶µ"
    RTBox.Text = RTBox.Text + PutString + Chr(10)

    '¬°¦U¼ÐÅÒ¤W¦â¥[©³½u
    For I = 0 To 2
        RTBox.SelStart = Mark(I).¶}©l¦ì¸m
        RTBox.SelLength = Mark(I).µ²§ô¦ì¸m - Mark(I).¶}©l¦ì¸m
        RTBox.SelUnderline = True
        RTBox.SelColor = RGB(0, 0, 255)
    Next

    '±N«ü¼Ð©ñ¦^ RTBox ¶}ÀY¡A¨Ã­Ý¦³®ø°£¿ï¨ú°Ï¶ô¤§§@¥Î
    RTBox.SelStart = 0

End Sub
Private Sub RTBox_Click()
Dim I As Long, Pointer As Long, MarkNum As Long
    '¥Î Pointer °O¦í´å¼Ð¥Ø«e¦ì¸m
    Pointer = RTBox.SelStart
    '§â¼ÐÅÒ½s¸¹¥ý³]¬° -1
    MarkNum = -1

    For I = 0 To 2
        '§Q¥Î Pointer §PÂ_´å¼Ð¬O§_¸¨¦b¼ÐÅÒ¦ì¸m¤º
        If Pointer < Mark(I).µ²§ô¦ì¸m And Pointer > Mark(I).¶}©l¦ì¸m Then
            '¨ú±o¼ÐÅÒ½s¸¹
            MarkNum = I
            Exit For
        End If
    Next

    'MarkNum=-1 ªí¥Ü¨S¿ï¨ì¼ÐÅÒ¡A<>-1 «h¨Ì¼ÐÅÒ½s¸¹¨ú¥X³sµ²
    If MarkNum <> -1 Then
        MsgBox "§A¿ï¾Ü¤F¾\Ū [" & Mark(MarkNum).³sµ²¦r¦ê & "] ³o½g¤å³¹"
    End If
End Sub
Private Sub RTBox_KeyDown(KeyCode As Integer, Shift As Integer)
    '¨¾¤î RTBox ³Q¨Ï¥ÎªÌ«ö Return Áä©î¦¨¨â¬q
    If KeyCode = 13 Then
        KeyCode = 0
    End If
End Sub
Private Sub RTBox_KeyPress(KeyAscii As Integer)
    '¸T¤î¨Ï¥ÎªÌªºÁä½L¿é¤J
    KeyAscii = 0
End Sub

¦^¯Á¤Þ


¶Ç°e¤G¶i¦ì¸ê®Æ


±H¥óªÌ: Chung Chien-shun

½Ð°Ý Winsock ¦p¦ó¥Î¦ì¤¸°}¦C¶Ç°e©M±µ¦¬

¦Ñ©Çµª¡G

  1. °e¤G¶i¦ìÀɮסG
    Dim FileHandle As Integer
    Dim SendBuff() As Byte
        FileHandle = FreeFile
        Open "YourFilePathAndName" For Binary As #FileHandle
        ReDim SendBuff(LOF(FileHandle) - 1)
        Get #FileHandle, , SendBuff
        Winsock1.SendData SendBuff
  2. °e¤G¶i¦ì¦r¦ê¡G
    Dim SendBuff() As Byte
    Dim SendString As String
        SendString = "§Q¥Î WinSock.SendData ¤G¶i¦ì¤è¦¡°e¦r¦ê"
        ReDim SendBuff(LenB(StrConv(SendString, vbFromUnicode)) - 1)
        SendBuff = SendString
        Winsock1.SendData SendBuff

¦^¯Á¤Þ


ProgressBar °ò¥»¹B§@¼Ò«¬


ProgressBar °ò¥»¹B§@¼Ò«¬¦p¤U¡G

Option Explicit

Private Sub Command1_Click()
Dim I As Integer
Dim HowLong As Date
    For I = ProgressBar1.Min To ProgressBar1.Max
        HowLong = Now
        ProgressBar1.Value = I
        Do While Second(Now - HowLong) < 1
        Loop
    Next
    ProgressBar1.Value = 0
    MsgBox "¬d¸ß§¹¦¨"
End Sub

Private Sub Form_Load()
    ProgressBar1.Max = 100
    ProgressBar1.Min = 0
End Sub

¦^¯Á¤Þ


¦bRTFÀɤ¤·j´M¬Y¤@­Ó¦r¦ê


Private Sub Command1_Click()
Dim Search As Long
    RichTextBox1.LoadFile "FilePath&Name.rtf"
    Search = RichTextBox1.Find("´M§ä¦r¦ê")

    If Search > -1 Then
        MsgBox "§ä¨ì¤F"
    Else
        MsgBox "¨S§ä¨ì"
    End If
End Sub

¦pªG¤£§Æ±æ Richtextbox Åã²{¥X¨Ó¡A¥i±N¨ä Visible=False

¦^¯Á¤Þ


ActiveX ¨Æ¥óªº²£¥Í


±H¥óªÌ: jojos

§Ú¦b½s¼g¦Û¤vªº ocx ®É, ½sÄÀ¥X¨Ó«á, ¥i¬Oµo²{¸ò¨ä¥¦ªº control ³£®t«Ü¦h, ¯Ê¤Ö¤F«Ü¦h¨Æ¥ó, ³o­Ó»Ý­n¨Ï¥Î¤°»ò¤~¯à°÷¼W¥[§Úªº control ¨Æ¥ó..´N¹³ control_Click, control_MouseMove, ³oÃþªºªF¦è...

¦Ñ©Çµª¡G

  1. §A¥²¶·¦³ Event «Å§i¤Î RaiseEvent ±Ô­z¡A¤j©è¤è¦¡¦p¤U¡G
    Option Explicit
    '¨Æ¥ó«Å§i:
    Event Click() 'MappingInfo=UserControl,UserControl,-1,Click
    Event DblClick() 'MappingInfo=UserControl,UserControl,-1,DblClick
    Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As
    Single) 'MappingInfo=UserControl,UserControl,-1,MouseMove

    Private Sub UserControl_Click()
    '¨Æ¥ó²£¥Íµ{§Ç
        RaiseEvent Click
    End Sub
    Private Sub UserControl_DblClick()
        RaiseEvent DblClick
    End Sub
    Private Sub UserControl_MouseMove(Button As Integer, Shift As Integer, X As
    Single, Y As Single)
        RaiseEvent MouseMove(Button, Shift, X, Y)
    End Sub
  2. §A¥i¥H¥Î [¼W¯q¶°]->[ActiveX ±±¨î¶µ¤¶­±ºëÆF]À°§A¦Û°Ê²£¥Í³o¨Ç¨Æ¥óªºµ{¦¡½X¡A¦pªG¨S¦³¦¹ºëÆF¡A½Ð¥Î[¼W¯q¥\¯àºÞ²z­û]·s¼W¡C

¦^¯Á¤Þ


¦p¦ó¦b SSTab ¤¤¤Á´«­¶ÅÒ


±H¥óªÌ: ªÖ©w¬O©p

SSTab(Tabctl32.ocx)±±¨î¶µ·Q¥Î¨ä¥¦¨Æ¥ó¡A´N¦Û°Ê¤Á¨ì§Ú·Qªº¨º¤@­¶¡C

¦Ñ©Çµª¡G

  1. ½Ð¨Ï¥Î SSTab ªº Tab¡BTabs¤Î TabCaption ÄÝ©Ê¡C
  2. .Print SSTab.Tabs ¦L¥X Tab Á`¼Æ
  3. SStab.Tab=0,1,2....n ³]©w¬Y½s¸¹ Tab ¬°²{¥Î Tab
  4. Print SSTab.TabCaption(Index) ¦L¥X¬YÃ丹¤§ TabCaption
  5. ¥Î Caption ³] Tab
    Dim Cap As String
    Dim I as Integer

        Cap="TabName"
        For I=0 to SStab.Tabs-1
            If SStab.TabCaption(I)=Cap Then
                SStab.Tab=I
                Exit For
            End If
        Next

¦^¯Á¤Þ


­I´º´`Àô¼½©ñ Wave ÀÉ


±H¥óªÌ: Wei-Shin Huang

§Ú¦³¤@­ÓWaveÀÉ¡A§Ú¥i¥H¥ÎMCIª«¥ó>Ū¨ú¥X¨Ó¡A¤]¥i¥H¼½©ñ¦¹ÀɮסC¦ý¬O§Ú·Q­«Âм½©ñ¦¹¤@ÀɮסA¥u»Ý¤U¤@¦¸©R¥O¡C½Ð°Ý¤@¤U¡A³o¸Ó«ç»ò°µ¡H

¦Ñ©Çµª¡G

¸Õ¸Õ©³¤U³o¬q Code ¡A§â MMControl1.filename ³]¬°ªø¤@ÂIªº­I´º­µ¼Ö¡AMMControl2.filename ³]¬°µuªºÄ²µo­µ¼Ö¡AµM«á«ö CommandButton ¸Õ¸Õ¡C±©¤@ªº¯Ê¾Ñ¬OIJµo­µ¼Ö®É­I´º­µ¼Ö·|¼È°±¡A¤£¼È°±­I´º­µ¼ÖIJµo­µ¼Ö¤S¥X¤£¨Ó¡AÁÙ¨S§ä¨ì«ç¼Ë¤~¯à¦³²V­µªº®ÄªG¡A¦pªG§A§ä¨ì¤F½Ð¤£§[§iª¾§Ú¡C

Option Explicit
Private Sub Command1_Click()
    MMControl1.Command = "Stop"
    '­«·s±Ò©l MCI WaveAudio ¶gÃä³]³Æ¡C
    MMControl2.Command = "Prev"
    MMControl2.Command = "Play"
End Sub
Private Sub Form_Load()
    '§â MMControl Âð_¨Ó¥H§K¼vÅT¹CÀ¸µe­±
    MMControl1.Visible = False
    MMControl1.Notify = False
    MMControl1.Wait = True
    MMControl1.Shareable = False
    MMControl1.DeviceType = "WaveAudio"
    MMControl1.filename = "C:\Win32App\Premiere\Samples\CIRCUS.WAV"

    MMControl2.Visible = False
    MMControl2.Notify = False
    MMControl2.Wait = True
    MMControl2.Shareable = False
    MMControl2.DeviceType = "WaveAudio"
    MMControl2.filename = "C:\Program
Files\Plus!\Pinball\Sounds\SOUND16.WAV"

    '¶}±Ò MCI WaveAudio ¶gÃä³]³Æ¡C
    MMControl1.Command = "Open"
    '¼½©ñ MCI WaveAudio ¶gÃä³]³Æ¡C
    MMControl1.Command = "Play"

    MMControl2.Command = "Open"
End Sub
Private Sub Form_Unload(Cancel As Integer)
    'Ãö³¬ MCI WaveAudio ¶gÃä³]³Æ¡C
    MMControl1.Command = "Close"
    MMControl2.Command = "Close"
End Sub

Private Sub MMControl1_Done(NotifyCode As Integer)
    '¦pªG¼½©ñ§¹²¦
    If NotifyCode = mciNotifySuccessful Then
        MMControl1.Command = "Play"
        '­«·s±Ò©l MCI WaveAudio ¶gÃä³]³Æ¡C
        MMControl1.Command = "Prev"
    End If
End Sub
Private Sub MMControl2_Done(NotifyCode As Integer)
    If NotifyCode = mciNotifySuccessful Then
        MMControl1.Command = "Play"
        MMControl2.Command = "Stop"
    End If
End Sub

¦^¯Á¤Þ


´¡¤J«ö¯Ã¹Ï¥Ü


  1. ToolBar ªº«ö¶s¹Ï¥Ü¬O¥Ñ Windows Common Control 5.0 ¦P²Õ¥t¤@­Óª«¥ó¥s ImageList ´£¨Ñªº¡A´N¦p¦P DBGrid ­n DataControl °µ DataSource ¤@¼Ë¡AToolBar ¬O­n©M ImageList °t®M¨Ï¥Îªº¡C
  2. ½Ð¦P®É¥¬¸m ImageList ©M ToolBar ¨â­Óª«¥ó¦b Form ¤W¡C
  3. ¦b ImageList ¹Ï¹³¨º­¶¤W´¡¤J§A·|¥Î¨ìªº¹Ï¥Ü¡C
  4. ¦b ToolBar ¤@¯ë¨º­¶ùØ¡A¦b¼v¹³®wùØ¿ï§Aªº ImageList ¡AµM«á¨ì«ö¶s¨º­¶´¡¤J«ö¶s¡A¨Ã¦b¼v¹³Äæ¼g§A­n¥Î Imagelist ùزĴX¸¹¹Ï¥Ü¡C
  5. §A©Î³\·|°Ý¡A¨º TreeView ©M ListView ¤]¬O³o¼Ë¥Îªº¶Ü¡A¬Oªº¡A¾ã­Ó Windows Common Control ´N¬O¥H Imagelist °µ¹Ï§Î®w¡C

¦^¯Á¤Þ


Node ª«¥óªº±²°Ê


±H¥óªÌ: ¿c©ú¼w

¦btreeview¤¤¡A·íDrag¤@­Ó NODE ¨ì³Ì©³¤Uªº Node ®É¡A¸Ó¦p¦óÅýTreeview±²°Ê¡AÅý§ó©³¤Uªº Node ¤W±²¡H

¦Ñ©Çµª¡G

  1. ¥»½d¨Ò¥Ü½d¦p¦ó¦b©ì¦² Node ª«¥óªº¹Lµ{¤¤¡A¦p¦ó¨Ï±²¶b°t¦X±²°Ê¡A¦Ó¯à¨Ï Node ±q²Ä¤@µ§©ì¨ì³Ì«á¤@µ§¡C
  2. ªí­±¤W³o­Ó¤u§@¤£§xÃø¡ANode ª«¥óªº EnsureVisible ¤èªk´N¯à¨Ïµøµ¡¥H¥~ªº Node ª«¥ó±²¨ìµøµ¡ùبӧe²{¡A¦]¦¹¦b§Ú­Ì¨ú±o Treeview.DropHighlight ª«¥ó«á¡A´N¯à¥Î Treeview.Nodes.Item(Treeview.DropHighLight.Index+1 or -1).EnSureVisible §â¤U'¤@­Ó Node ª«¥ó±²¨ìµøµ¡ùبӡC
  3. ¦ý§Ú­Ì¤£­n§Ñ¤F¡ATreeview ¬O­Ó¾ðª¬ª«¥ó¡A¨ã¦³¶¥¼h©Ê¡C°£«D§Ú­Ì TreeView ¥u¦³¤@¼h¡A'¨Ã¥B§Ú­Ì¦b Add Node ª«¥ó®É¨S¦³°µ¦V«e´¡¤Jªº°Ê§@¡A§_«h TreeView.Nodes(Index) ªº Index ¦¸§Ç©M¹ê»Ú¤W Node ª«¥ó¥X²{¦bµøµ¡¤¤ªº¦¸§Ç¬O§¹¥þ¤£¤@¼Ëªº¡A¦p¥»¨Ò¡A¥H¤U¦Cªí¥ªÃä¬O TreeView Node ´¡¤J¦¸§Ç¡A¥kÃä«h¬O¹ê»Úµøµ¡¤¤ªº¶¥¼h¦¸§Ç¡G
    'Parent1:1
    'Parent2:10
    'Child 1:2
    'Child 2:9
    'Child 3:11
    'Child 4:12
    'Child 5:3
    'Child 6:4
    'Child 7:5
    'Child 8:6
    'Child 9:7
    'Child 10:8
    ¤]´N¬O»¡¥ÎTreeview.Nodes.Item(Treeview.DropHighLight.Index+1 or -1)§ì¨ìªºª«¥ó®Ú¥»¤£¬O¹ê»Ú¦bµøµ¡¤¤ªº¤U¤@­Ó Node¡A³Â·Ðªº¬O TreeView ¨Ã¨S¦³¹ê»Ú¥i¨ú±o¶¥¼h±Æ¦C¦¸§ÇªºÄÝ©Ê(¤]¥i¯à¬O§Ú¨S§ä¨ì¡A§Æ±æª¾¹Dªº¤H¯à§i¶D§Ú¡C)
  4. ©Ò¥H§Ú§Q¥Î¤@»¼°jµ{¦¡¡A§â TreeView Node ªº¶¥¼h¦¸§Ç©ñ¦b¤@¼Æ­È°}¦CùØ¡A¦p¦¹´N¯à³z¹L°}¦C«ü¼Ð§ä¥X¬Y¤@ Node ¦b¶¥¼h¤¤ªº«e¤@­Ó¤Î«á¤@­Óª«¥ó¡C
  5. °õ¦æ¥»½d¨Ò½Ð¨Ï¥Î Microsoft Windows Common Control 5.0 ¤¸¥ó¡A¨Ã©óªí³æ¤W
    ¥¬¸m
    'TreeView1,ImageList1

    Option Explicit
    'Node ¶¥¼h¦¸§Ç«ü¼Ð
    Dim AddNo As Integer
    '¦s©ñ Node ¶¥¼h¦¸§Çªº¼Æ­È°}¦C
    Dim Serial() As Integer
    '«e¤@­Ó Node ªº Index ­È
    Dim OldRec As Integer
    '«Å§i¥þ°ìÅܼơC
    Dim indrag As Boolean '«ü¥Ü©ì©ñ°Ê§@ªººX¼ÐÅܼơC
    Dim nodX As Object '¥¿³Q©ì¦²ªº¶µ¥Ø¡C

    Private Sub Form_Load()
        '¦b Imagelist ±±¨î¶µ¤¤¸ü¤J¤@­ÓÂI°}¹Ï¡C
        Dim imgX As ListImage
        Dim BitmapPath As String
        BitmapPath = "c:\icons\drives.ico"
        Set imgX = ImageList1.ListImages.Add(, , LoadPicture(BitmapPath))

        'ªì©l¤Æ TreeView ±±¨î¶µ¡A¨Ã«Ø¥ß¦h­Ó¸`ÂI¡C
        TreeView1.ImageList = ImageList1
        Dim nodX As Node    '«Ø¥ß¾ðª¬¡C
        Set nodX = TreeView1.Nodes.Add(, , , "Parent1", 1)
        Set nodX = TreeView1.Nodes.Add(, , , "Parent2", 1)
        Set nodX = TreeView1.Nodes.Add(1, tvwChild, , "Child 1", 1)
        Set nodX = TreeView1.Nodes.Add(1, tvwChild, , "Child 2", 1)
        Set nodX = TreeView1.Nodes.Add(2, tvwChild, , "Child 3", 1)
        Set nodX = TreeView1.Nodes.Add(2, tvwChild, , "Child 4", 1)
        Set nodX = TreeView1.Nodes.Add(3, tvwChild, , "Child 5", 1)
        Set nodX = TreeView1.Nodes.Add(7, tvwChild, , "Child 6", 1)
        Set nodX = TreeView1.Nodes.Add(7, tvwChild, , "Child 7", 1)
        Set nodX = TreeView1.Nodes.Add(9, tvwChild, , "Child 8", 1)
        Set nodX = TreeView1.Nodes.Add(10, tvwChild, , "Child 9", 1)
        Set nodX = TreeView1.Nodes.Add(11, tvwChild, , "Child 10", 1)
        nodX.EnsureVisible '®i¶}¾ðª¬¡A¥HÅã¥Ü¥þ³¡¸`ÂI¡C

        '³]©w»P TreeView1.Nodes ¦P¼Æ¥Øªº°}¦C¡ANodes ªº Index °ò©³¬° 1¡A
        '¬G Serial ¤]³]°ò©³¬° 1¡C
        ReDim Serial(1 To TreeView1.Nodes.Count)
        '°õ¦æ®i¶} TreeView ¨Ã°O¿ý¶¥¼h¦¸§Çªº¦Û­q»¼°j¨ç¼Æ
        ExpandTree nodX.Root
        '¥ý±N«e¤@­Ó Node ªº Index ­È³]¬°®Ú Node ªº Index
        OldRec = nodX.Root.Index
    End Sub

    Private Sub TreeView1_MouseDown(Button As Integer, Shift As Integer, x As
    Single, y As Single)
        Set nodX = TreeView1.SelectedItem '³]©w­n©ì¦²ªº¶µ¥Ø¡C
    End Sub

    Private Sub TreeView1_DragDrop(Source As Control, x As Single, y As Single)
        If TreeView1.DropHighlight Is Nothing Then
            Set TreeView1.DropHighlight = Nothing
            indrag = False
            Exit Sub
        Else
            If nodX = TreeView1.DropHighlight Then Exit Sub
            Cls
            Print nodX.Text & " dropped on " & TreeView1.DropHighlight.Text
            Set TreeView1.DropHighlight = Nothing
            indrag = False
        End If
    End Sub

    '¦¹ DragOver µ{§Ç¬°¥»½d¨Ò­«ÂI
    Private Sub TreeView1_DragOver(Source As Control, x As Single, y As Single,
    State As Integer)
        On Error GoTo IgnoreHighLightNotSet
        If indrag = True Then
            '³]©w DropHighlight ¬°·Æ¹«®y¼Ð¡C
            Set TreeView1.DropHighlight = TreeView1.HitTest(x, y)
            '°õ¦æ¥Î Nodes.Index §ä Nodes ¶¥¼h Index ªº¦Û­q¨ç¼Æ
            TreeView1.Nodes.Item(GotNodeSerial(TreeView1.DropHighlight.Index, _
                    OldRec)).EnsureVisible
            '§â«e¤@­Ó Node ªº Index ­È³]¬° DropHighlight ªº Index
            OldRec = TreeView1.DropHighlight.Index
        End If
    IgnoreHighLightNotSet:

        Select Case Err.Number
            Case 0
            Case 91
                'Err.Number = 91 ¬O¨S¦³³]©wª«¥ó¡A¤]´N¬O HitTest(x,y) ªº x,y ®y¼Ð
    ¨S¦³
                '¥¿½T¸¨¦b¬Y Node ¤W¡A¦Ó¬O¸¨¦bªÅ¥Õ°Ï¤W¡C¦]¬°¸¨¦bªÅ¥Õ°Ï«h
    HitTest(x,y)
                '§ì¨ìªº Node ¬OªÅªº¡A¦]¦¹¨ä«áªºµ{¦¡½X·|²£¥Í¿ù»~¡A¬°¤FÁקKµ{¦¡²£
    ¥Í¿ù»~
                '°T®§¡A©Ò¥H³oùØ¥[¤@­Ó¿ù»~³B²zµ{§Ç¡C
            Case Else
                MsgBox Err.Description, vbOKOnly, "¿ù»~¥N½X¡G" & Err.Source
        End Select
    End Sub

    Private Sub TreeView1_MouseMove(Button As Integer, Shift As Integer, x As
    Single, y As Single)
        If Button = vbLeftButton Then '«ü¥Ü¤@­Ó©ì¦²°Ê§@¡C
            indrag = True '³]©wºX¼ÐÅܼƬ° true¡C
            '¨Ï¥ÎCreateDragImage¤èªk³]©w©ì¦²¹Ï¥Ü¡C
            TreeView1.DragIcon = TreeView1.SelectedItem.CreateDragImage
            TreeView1.Drag vbBeginDrag '©ì¦²°Ê§@¡C
        End If
    End Sub

    '®i¶} TreeView ¨Ã°O¿ý Nodes ¶¥¼h¦¸§Çªº¦Û­q»¼°j¨ç¼Æ
    '­«ÂI¬O ExNode °Ñ¼Æ¤@©w­n¬O Nodes ªº Root Node ª«¥ó¡A
    '§_«hµ{¦¡·|¤£¥¿½T
    Private Sub ExpandTree(ByVal ExNode As Node)
    '¸Ó¶¥¼h³Ì«á¤@­Ó Node ª«¥ó
    Dim LastNode As Node
    'ºtºâ¥Îªº Node ª«¥ó
    Dim TempNode As Node

        Set LastNode = ExNode.LastSibling
        Set TempNode = ExNode
        AddNo = AddNo + 1
        '§â¶¥¼h¦¸§Ç­È©ñ¤J¬Û¹ïÀ³ Nodes ªº Index «ü¼Ð¤¤¡A¥H«K¨Ñ¥H«áµ{¦¡ªº¨Ï¥Î
        Serial(TempNode.Index) = AddNo
        '¦pªG Node ©³¤UÁÙ¦³¤l Node
        If TempNode.Children > 0 Then
            '©I¥s»¼°j³B²z
            ExpandTree TempNode.Child
        End If

        Do
            '¦pªG Node ¤w¬O¸Ó¶¥¼h³Ì«á¤@­Ó Node «hµ²§ô Loop
            If TempNode = LastNode Then
                Exit Do
            End If

            '«ü¦V¦P¶¥¼h¤U¤@­Ó Node
            Set TempNode = TempNode.Next
            AddNo = AddNo + 1
            Serial(TempNode.Index) = AddNo
            If TempNode.Children > 0 Then
                ExpandTree TempNode.Child
            End If
        Loop
    End Sub

    '¥Î Nodes Index ´M§äµøµ¡¶¥¼h¤¤¤U¤@­Ó Node ªº Index ­È
    'NodeIndex ¬O DropHighLight.Index ­È
    'OldIndex ¬O¤W¤@¦¸ DropHighLight.Index ­È
    '¥Î¦¹¤G Index ¨Ó§PÂ_¬O¦V«e©Î¦V«á±²°Ê
    Private Function GotNodeSerial(ByVal NodeIndex As Integer, _
            ByVal OldIndex As Integer) As Integer
    Dim I As Integer
    '­n EnsureVisible Node ªº ¶¥¼h¦¸§Ç­È
    Dim SerialNo As Integer
        '­nª`·N¬O³o¸Ì¤ñ¸ûªº¬O¬Û¹ïÀ³©ó Nodes Index «ü¼Ðªº
        'Serial °}¦C¤¸¯À­È(¥ç§Y Nodes ªº¶¥¼h¦¸§Ç)¡A¦Ó¤£¬Oª½±µ¥Î Nodes Index ¨Ó¤ñ
        '¥Î Index ¨Ó¤ñ¥¿¦p§Ú¶}ÀY©Ò¨¥¡A¬O¿ù»~ªº¡C
        Select Case Serial(NodeIndex) - Serial(OldIndex)
            '·s«ü¼Ð¤ñ«ü¼Ð¤j¡Aªí¥Ü¦V¤U±²
            Case Is > 0
                If Serial(NodeIndex) < UBound(Serial) Then
                    SerialNo = Serial(NodeIndex) + 1
                Else
                    SerialNo = Serial(NodeIndex)
                End If
            '·s«ü¼Ð¤ñ«ü¼Ð¤p¡Aªí¥Ü¦V¤W±²
            Case Is < 0
                If Serial(NodeIndex) > 1 Then
                    SerialNo = Serial(NodeIndex) - 1
                Else
                    SerialNo = Serial(NodeIndex)
                End If
            '¨S§ïÅܤ£¥Nªí¤£¶·³B²z¡A¦]¬° SerialNo ªì­È¬O 0 ¡A¦Ó Serial °}¦CùبèS
    ¦³
            '¯Á¤Þ­È¬O 0 ªº¤¸¯À¡C
            Case Else
                SerialNo = Serial(NodeIndex)
        End Select

        '§ä§ä¬Ý¦b Serial °}¦C¤¤¡AÂ\©ñ SerialNo ªº¬O²Ä´X­Ó°}¦C¤¸¯À¡A¨ä«ü¼Ð§Y
        'µ¥©ó Nodes Index ­È¡C
        For I = 1 To UBound(Serial)
            If Serial(I) = SerialNo Then
                GotNodeSerial = I
                Exit For
            End If
        Next
    End Function

¦^¯Á¤Þ


Nodes.Add ¤èªk°Ñ¼Æ¸Ô¸Ñ


©¾©ó¦Û¤v©¾©ó­ì¨ý ¼¶¼g©ó¤å³¹

treeviewª«¥ó¦b form_load®É«ç»ò¼Ë¼g¤~¤£·|Åýtreeview¸Ì¨S¦³ªF¦è°Ú!!!

¦Ñ©Çµª¡G

  1. ­n¥Î Treeview.Nodes ¶°¦Xª«¥óªº Add ¤èªk¨Ó¥[¤J¡C
  2. »yªk¡G
    Dim AddNode As Node
    Set AddNode=TreeView.Nodes.Add(relative, relationship, key, text, image,selectedimage)
  3. ¥ý­n¤F¸Ñ TreeView ¶¥¼hÃö«Y¦p¦ó«Ø¥ß¡A´N­n©ú¥Õ relationship °Ñ¼Æ¡G
  4. key ¿ï¾Ü©Êªº¡C³æ¤@¯S©wªº¦r¦ê¡A¥Î¨Ó¥H Item ¤èªkÀ˯Á Node¡C
    ·í§A¥Î Set AddNode = TreeView.Nodes.Add(,, "E", "Node 5") ³]©w
    key="E" ®É
    §A´N¥i¥H¥Î Print Treeview.Nodes.Item("E").Text ¨Ó¨ú±o¸Ó Node ªº¤Þ¥Î¡C
  5. text ¥²»Ýªº¡C¦b Node ¤¤¥X²{ªº¦r¦ê¡C
    ¦p¥»¨Ò¤¤ªº "Node 1"¡B"Node 2"......
  6. image ¿ï¾Ü©Êªº¡C
    ·í§A­n¬° Node ¥[¤W¹Ï¥Ü¼v¹³®É¡A§A¥²¶·¨Ï¥Î ImageList ±±¨î¶µ
    ¦p
    Dim imgX As ListImage
    Dim BitmapPath As String

        BitmapPath = "c:\icons\drives.ico"
        Set imgX = ImageList1.ListImages.Add(, , LoadPicture(BitmapPath))
        '¥Î ImageList1 °µ TreeView1 ªº¼v¹³®w
        TreeView1.ImageList = ImageList1
        'µM«á§A¥i¥H¥Î
        Set AddNode = TreeView1.Nodes.Add(, , "B", "Node 1", 1)
        '¬°§Aªº Node ¥[¤W Icon ¼v¹³¡A1 ªí¥Ü¥Î ImageList ùتº²Ä¤@±i¹Ï
  7. selectedimage  ¿ï¾Ü©Êªº¡C
    ·í Node ³Q¿ï¨ú®É¡A©Ò­nÅã¥Üªº¹Ï¥Ü¡C
    ¥Î
        BitmapPath = "c:\icons\fax.ico"
        Set imgX = ImageList1.ListImages.Add(, , LoadPicture(BitmapPath))
    ¦A¥[¤@±i¹Ï¡AµM«á
        Set AddNode = TreeView1.Nodes.Add(, , "B", "Node 1", 1, 2)
        '«h·í§A¦b Node ¤W Click ¤@¤U«á¡A·|µoı¸Ó Node ©M¨ä¥L Node ·|¦³¤£¤@¼Ëªº¹Ï
    ¥Ü¡A2 ªí¥Ü¨Ï¥Î ImageList ²Ä¤G±i¹Ï¡C
  8. ¨ä¥L Node and Nodes ¾Þ§@¤èªk½Ð¨Ï¥ÎÂsÄýª«¥ó¥\¯à¨ú±o¬ÛÃö»¡©ú¡C
  9. ¥þ³¡µ{¦¡½X¦p¤U(°O±o¦b Form ¤W©ñ TreeView1¡BImageList1)¡G
    Option Explicit
    Private Sub Form_Click()
        Cls
        Print TreeView1.Nodes.Item("E").Text
    End Sub

    Private Sub Form_Load()
    Dim AddNode As Node
    '¦b Imagelist ±±¨î¶µ¤¤¸ü¤J¤@­ÓÂI°}¹Ï¡C
    Dim imgX As ListImage
    Dim BitmapPath As String

        BitmapPath = "c:\icons\drives.ico"
        Set imgX = ImageList1.ListImages.Add(, , LoadPicture(BitmapPath))
        BitmapPath = "c:\icons\fax.ico"
        Set imgX = ImageList1.ListImages.Add(, , LoadPicture(BitmapPath))
        'ªì©l¤Æ TreeView ±±¨î¶µ¡A¨Ã«Ø¥ß¦h­Ó¸`ÂI¡C
        TreeView1.ImageList = ImageList1
        Set AddNode = TreeView1.Nodes.Add(, , "B", "Node 1", 1, 2)
        Set AddNode = TreeView1.Nodes.Add(1, tvwNext, "C", "Node 2", 1, 2)
        Set AddNode = TreeView1.Nodes.Add(2, tvwFirst, "A", "Node 3", 1, 2)
        Set AddNode = TreeView1.Nodes.Add(1, tvwLast, "F", "Node 4", 1, 2)
        Set AddNode = TreeView1.Nodes.Add(4, tvwPrevious, "E", "Node 5", 1, 2)
        Set AddNode = TreeView1.Nodes.Add(2, tvwChild, "D", "Node 6", 1, 2)
    End Sub

¦^¯Á¤Þ


¦^­º­¶

1