VB5 ªì¯Å¥Í ¦Ñ©Ç½d¨Ò(¤E)

¦^­º­¶


¤ÀÃþ

¼ÐÃD

¤j·N

§@ªÌ

¤é´Á

µøµ¡¬É­± ÅÜ´«¦P¦æ¦r¦ê¤§¦rÅé¤j¤p ¡@ ¦Ñ©Ç 1999/3/1
µøµ¡¬É­± ¦b Form ¤W¦C¦L¶W¹L Form ªø«×¸ê®Æ ¡@ ¦Ñ©Ç 1999/3/7
µøµ¡¬É­± ¦p¦ó°ÊºA·s¼Wªí³æ ª«¥ó¤@¼Ë¥i¥H¥Î°ÊºA°}¦C ¦Ñ©Ç 1999/3/29
µøµ¡¬É­± ¦P®É©T©wªí³æ¤ÎÅã¥Ü³Ì¤p¤Æ«ö¶s ¡@ ¦Ñ©Ç 1999/5/4
µøµ¡¬É­± ¨Ï¥Î·Æ¹«¥kÁä¥s¥X¿ï³æ PopupMenu ¤èªk ¦Ñ©Ç 1999/5/9
¹Ï§Î³B²z ¨ú±o BMP ¹Ï§ÎÃC¦â¼Æ ¡@ Sun Jack 1999/3/20
¹Ï§Î³B²z ¤@¤j¹Ï¤Á¦¨¼Æ¤p¹Ï PaintPicture °Ñ¼Æªº¨Ï¥Î ¦Ñ©Ç 1999/4/8
¹Ï§Î³B²z ¦A½× PaintPicture ªº³B²z°Ê§@ PictureBox ªº¹Ï¼hÆ[©À ¦Ñ©Ç 1999/4/13
¹Ï§Î³B²z ²©ö¤ô¤¤­Ë¼v¸Õ°µ PaintPicture °Ñ¼Æªº¨Ï¥Î ¦Ñ©Ç 1999/4/16
±±¨î¶µ¨Ï¥Î §Y®ÉÅã¥Ü Scroll.Value ¡@ ¦Ñ©Ç 1999/3/11
±±¨î¶µ¨Ï¥Î Åý Combo.AddItem ¤£­«ÂÐ ¡@ ¦Ñ©Ç 1999/5/16
OCX »s§@ ¦p¦ó§@¥iÂI¿ïÃC¦âªº Property OLE_COLOR ª«¥ó ¦Ñ©Ç 1999/4/9
OCX »s§@ ¦p¦ó³]©wDefault Property ¡@ ¦Ñ©Ç 1999/4/9
ª«¥ó¨Ï¥Î ¦p¦ó§ó§ï¦Lªí¾÷ªº¯È±i¤j¤p³]©w ¥¿½Tªº¾Þ§@ PaperSize ÄÝ©Ê ¦Ñ©Ç 1999/4/2
ª«¥ó¨Ï¥Î ¥Îª«¥ó¦WºÙ¦r¦ê¾Þ§@ª«¥ó Controls ¶°¦Xª«¥óªº¨Ï¥Î Sun Jack 1999/5/6
¬yµ{±±¨î ¦p¦ó°µ¥X VB Delay() ¡@ ¦Ñ©Ç 1999/3/19
¤é´Á®É¶¡ ¦p¦óÅý VB Show ¥X¦Ê¤À¤§¤@¬í ¡@ ¦Ñ©Ç 1999/3/20
¤é´Á®É¶¡ ¥Î Format ²£¥Í¥Á°ê¦~¥÷ ¡@ Sun Jack 1999/3/21
¤é´Á®É¶¡ ªø®É¶¡±Æµ{³qª¾ Timer ª«¥ó¨Ï¥Î ¦Ñ©Ç 1999/4/25
ÅܼƳB²z Form Unload «áÅܼƦû¥Î°O¾ÐÅ骬ªp ¡@ ¦Ñ©Ç 1999/4/25

VB5 ªì¯Å¥Í½d¨Ò¨Ï¥Î»¡©ú


  1. ¥»½d¨ÒÅwªï«DÀç§Q©Ê­Ó¤H¤Î²Õ´Âà¸ü¨Ï¥Î¡AÀç§Q¤§§Q¥Î½Ð¥ý¼x±o¥»¤H¤§¦P·N¡A¨Ó«Hµù©ú¨Ï¥Î¤è¦¡¤Î¦^ÂЦa§}¡C
  2. ¥»½d¨Ò©Ò¦³ªºµ{¦¡½X½d¨Ò¡A¬ÒÄݤQ¤À°ò¥»ªº VB »yªk¡A¦pªG±z¬O­Ó VB User ¡AÅwªïª½±µ¤Þ¥Î©Î§ï¼g¨Ï¥Î¦b§Aªºµ{¦¡¤¤ ¡A¥»¤H¤£¥D±iµÛ§@Åv¡A¦]¬°¡A¨S¿ìªk¬d¹À¡C
  3. ¦pªG§A¬O­Ó VB ªì¾ÇªÌ¡A¤S¦³ÂI½a½a(©M¦Ñ©Ç¤@¼Ë)¡A»°§Ö§â¥»­¶¥t¦s·sÀɨì§A¦Û¤vªººÏºÐ¡AÂ÷½u«áºCºC¬Ý¡A¤]¥i¥H Copy µ¹ªB¤Í³á(¤£¥i¥H¦¬¿ú)¡C
  4. ¥»½d¨Ò³£¬O¦Ñ©Ç´X­Ó¤ë¨Ó¦b tw.bbs.comp.language °Q½×¸s²Õ¤¤¦^µªª©¤Í°ÝÃDªº¦X¿è¡A¦]¬°¬O°w¹ï°ÝÃD¸Ñ¨M¡A©Ò¥H¨Ã¨S¦³¥þ­±Æ[©Àªº¸Ñ»¡¡A¤£¾A¦X§@¬°¤Jªù¤å³¹¡A¦ý¦pªG§AŪ¤F¤Jªù®Ñ¡A©Î¬O¤W¤F¦Ñ®vªº½Ò¡A¤ß¤¤¤´¤£¬Æ©ú¥Õªº¸Ü¡A´N¥i¥H¨Ó³o§ä§ä¦³¨S¦³§A­nªºµª®×¡A¦]¬°³o³£¬O§O¤H°Ý¹Lªº°ÝÃD¡C

¦^¯Á¤Þ


ÅÜ´«¦P¦æ¦r¦ê¤§¦rÅé¤j¤p


  1. ¥ýºâ¥X¦P¦æ¦r¦ê¤¤¡A³Ì¤j¦r«¬¬O¦h¤Ö Height ¨Ó¨M©w¦æ°ª¡C
  2. ¨Ì¦æ°ª´î¥h¦U§O¦rÅé°ª«×¨Ó½Õ¾ã CurrentY ªº¦ì¸m¡C
  3. µ{¦¡½d¨Ò¦p¤U¡G
    Private Sub Form_Click()
    Dim oldX As Single, oldY As Single
    Dim PString As String

        oldY = CurrentY
        oldX = CurrentX

        FontSize = 14
        CurrentY = ScaleY(30, vbPixels, Me.ScaleMode) - TextHeight(PString)
        PString = "§Ú­Ì"
        Print PString
        oldX = oldX + TextWidth(PString)
        FontSize = 10
        CurrentX = oldX
        CurrentY = ScaleY(30, vbPixels, Me.ScaleMode) - TextHeight(PString)
        PString = "·Q­n"
        Print PString
        oldX = oldX + TextWidth(PString)
        CurrentX = oldX
        FontSize = 18
        CurrentY = ScaleY(30, vbPixels, Me.ScaleMode) - TextHeight(PString)
        PString = "¥X¥hª±"
        Print PString
    End Sub

¦^¯Á¤Þ


¦b Form ¤W¦C¦L¶W¹L Form ªø«×¸ê®Æ


»{....¯u(male) ¼¶¼g©ó¤å³¹

¬O§_¦nªº¤èªk¥i¥Î¤@­Óªí³æ¥i¥HÅã¥Ü¤Î¦C¦LµL­­¶µµ²ªG??

¦Ñ©Çµª¡G

¨Ï¥ÎÅܼư}¦C¤ÎÅã¥Ü«ü¼Ð¡A¦A¤À¬q¦b Form ¤WÅã¥Ü¡AÄ´¦p¡G
Dim ­pºâµ²ªG°}¦C() As Variant
Dim Åã¥Ü«ü¼Ð As Long

1.­pºâ©Ò¦³µ²ªG¡G

Redim ­pºâµ²ªG°}¦C(0)
Do
    If ­pºâÄ~Äò Then
        ­pºâµ²ªG°}¦C(0)=­pºâµ²ªG
        ReDim Preserve ­pºâµ²ªG°}¦C(Ubound(­pºâµ²ªG°}¦C)+1)
    Else
        Exit Do
    End IF
Loop

2.³]©wÅã¥Ü«ü¼Ð
Select Case KeyCode
    Case vbKeyPageUp
        Åã¥Ü«ü¼Ð=Åã¥Ü«ü¼Ð-1
    Case vbKeyPageDown
        Åã¥Ü«ü¼Ð=Åã¥Ü«ü¼Ð+1
End Select

3.¦b Form ¤WÅã¥Üµ²ªG
Dim I As Integer
Me.Cls
    For I=Åã¥Ü«ü¼Ð*10 TO Åã¥Ü«ü¼Ð*10+9    'Ä´¦p¤@¦¸Åã¥Ü¤Qµ§¸ê®Æ
        Form.Print ­pºâµ²ªG°}¦C(I)
    Next

¥H¤W¤j·N¦p¦¹¡A§A¦A°t¦X¦Û¤vªºµ{¦¡­×§ï¡C

¦^¯Á¤Þ


§Y®ÉÅã¥Ü Scroll.Value


w101 ¼¶¼g©ó¤å³¹

¨Ï¥Î VScroll or HScroll «öµÛ·Æ¹«²¾°Ê®É, ¥i§Y®Éªº¶Ç¦^¥¦ªº²¾°Ê¶q¶Ü??

¦Ñ©Çµª¡G

§Y®ÉÅã¥Ü²¾°Ê¶q­n¨Ï¥Î Scroll Event ¡AChange Event ¬O©ñ¶}·Æ¹«¤~·|Åã¥Üªº¡C½d¨Ò¦p¤U¡G
Private Sub Form_Load()
    HScroll1.Max = 100
    HScroll1.Min = 1
End Sub

Private Sub HScroll1_Scroll()
    Text1.Text = HScroll1.Value
End Sub

¦^¯Á¤Þ


¦p¦ó°µ¥X VB Delay()


¨Ìµ·©« ¼¶¼g©ó¤å³¹

½Ð°Ý¤@¤U¦³½Öª¾¹Dvbªº ¦³¨S¦³delayªº«ü¥O...

¦Ñ©Çµª¡G

  1. ¦n¹³¨S¦³¡A¤£¹L¦Û¤v¼g¤]¤£Ãø¡A½d¨Ò¦p¤U¡G

    Private Sub Delay(Optional ByVal HowLong As Single)
    Dim OldTime As Single, Continue As Single
        If HowLong = 0 Then
            Exit Sub
        Else
            If HowLong < 0.01 Then
                MsgBox "©µ¿ð®É¶¡µLªk¤p©ó 0.01 ¬í", vbOKOnly, "°Ñ¼Æ¿ù»~"
                Exit Sub
            End If
        End If

        OldTime = Timer

        Do While Continue < HowLong
            Continue = Timer - OldTime
        Loop

    End Sub
  2. ©I¥s¤è¦¡¡G
    Delay ¬í¼Æ

¦^¯Á¤Þ


¦p¦óÅý VB Show ¥X¦Ê¤À¤§¤@¬í


jay ¼¶¼g©ó¤å³¹

½Ð°Ý¦b VB ¤¤,¦p¦ó¦C¦L¥X¦Ê¤À¤§¤@¬í©O? ¦p 17:59:00.10 or 17:58:20:30¡C

¦Ñ©Çµª¡G

  1. '¥»¨ç¼Æ¶È¥Nªí¬ù²¤ªº§ó¤p¬í¼ÆÅã¥Ü¡A¤£«Øij°µºë½T­p¼Æ¥Î¡C
    Private Function MicroSecond() As String
    Dim mSec As Single
        mSec = Time

        MicroSecond = Format(mSec, "hh:mm:ss") & ":" & _
                Mid(CStr(mSec), 8, 2)

                'Mid(CStr(mSec), 8, 2)¥Î·N¦b¨ú¤p¼ÆÂI«á 6,7 ¨â¦ì¼Æ¦r¡A
                '¦]¬°¤@¯ë VB ¬O±Ä¥Î¤p¼ÆÂI«á¤­¦ì¼Æ¦r°µ¬°®É¶¡­p¼Æ¥Î¡A¤]´N¬O±q
                '¤È©] 00:00 °_¨C¹L¤@¬í´N¥[ 0.00001 ¡A¤ñ 0.00001 §ó¤pªº­p¼Æ«h
                '¤£Åã¥Ü¡A§Ú­Ì­n¨ú§ó¤p¼Æ­È´N­n¤­¦ì¼Æ¥H¤U¤§¼Æ­È¡C²Ä¤»¦ì¼Æ¦p¥[¤W
                '«e¸m¹s¸¹¤Î¤p¼ÆÂI¡A­è¦n¬O¦r¦êªº²Ä¤K¦r¤¸¡A¬G¦p¦¹§ì¨ú¡C
    End Function
  2. ©I¥s¤è¦¡¡G
    Print MicroSecond ©Î varString=MicroSecond¡A¤£¶·¶Ç¤J°Ñ¼Æ¡C

¦^¯Á¤Þ


¥Î Format ²£¥Í¥Á°ê¦~¥÷


Print Format(Now,"eemmdd")

¦^¯Á¤Þ


¦p¦ó°ÊºA·s¼Wªí³æ


¶§¥ú¤Uªº¨k«Ä ¼¶¼g©ó¤å³¹

§Ú¼g¤F2­ÓForm¤À§O¬°Form1¤ÎForm2

  1. Form1¬°¥Dµe­±,§Ú§Æ±æ¦bForm1®É«ö¤UAlt+A®É,¥i¥H¥s¥X¤@­ÓForm2.
  2. ±µµÛ,¦bForm2µe­±©ÎªÌForm1µe­±®É,«ö¤UAlt+B¤S¥i¥HÄ~Äò¥s¥X¤@­Ó·sªºForm2.
  3. ¥i¥H¤@ª½¦b·s©Î Form µe­±Ä~Äò¥s¥X¥t¤@­Ó Form .

¦Ñ©Çµª¡G

  1. ¹ï©óµ{¦¡°õ¦æ¤¤·|¶}±Ò¤£½T©w¼Æ¥Øªºªí³æ¡A¥H¨Ï¥Î Form ª«¥óªº°ÊºA°}¦C³Ì¬°«K§Q¡A½d¨Ò¦p¤U¡G
  2. '------------------  Module1.Bas Start  -------------------
    Option Explicit
    Public ExtForm1() As Form
    Public ExtForm2() As Form
    Public Form1No As Long
    Public Form2No As Long
    '------------------  Module1.Bas End  -------------------
  3. '-------------  Form1 & Form2 Start  ---------------------
    Option Explicit
    Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
        If Shift And vbAltMask Then
            Select Case KeyCode
                Case vbKeyA
                    ReDim Preserve ExtForm1(Form1No)
                    Set ExtForm1(Form1No) = New Form1
                    ExtForm1(Form1No).Show
                    Form1No = Form1No + 1
                Case vbKeyB
                    ReDim Preserve ExtForm2(Form2No)
                    Set ExtForm2(Form2No) = New Form2
                    ExtForm2(Form2No).Show
                    Form2No = Form2No + 1
            End Select
        End If
    End Sub
    '-------------  Form1 & Form2 End  ---------------------

¦^¯Á¤Þ


¦p¦ó§ó§ï¦Lªí¾÷ªº¯È±i¤j¤p³]©w


eeyore ¼¶¼g©ó¤å³¹

¦]¬°§Úªº±M®×¶·­n«Ü¦hºØ³øªí®æ¦¡ ¦p A4,LETTER SIZE¡A§Ú¨Ï¥Î VBªº PRINTER.PAPERSIZE ¥h§ó§ï³]©w¦ý¬O¨S¦³§@¥Î  !!!!·Q½Ð±Ð¦U¦ì¥ý¶i,¦³¨º¤@­Ó C++ OR API OR VB «ü¥O¥i¥H°ÊºA³]©w¦Lªí¾÷ªºª¬ºA¡C

¦Ñ©Çµª¡G

  1. §A¤£»Ý­n C++ or API ¡A§A¥u¶·­n¦b VB ùØ°µ¥X¥¿½Tªº³]©w¡A¤@©w¥i¥H¥Î Printer.PaperSize ¥h§ó§ï¯È±i³]©w¡A¦Ó©Ò¿×¥¿½T³]©w¡AÀ³¸Ó¥]§t¤U¦C´X¥ó¨Æ¡G
  2. ¦¹¥~¤ñ¥²¶·ª`·N¡A·í§A§ïÅܤF¦Lªí¾÷ Height ©M Width Äݩʳ]©w®É·|¦Û°Ê±N PaperSize ³]©w¬° vbPRPSUser(¨Ï¥ÎªÌ¦Û­q)¡C
  3. '--------------------  ¦Lªí¾÷³]©w½d¨Ò¶}©l  --------------------------
    VERSION 5.00
    Begin VB.Form frmPrinterSet
       Caption         =   "¦Lªí¾÷³]©wªí³æ"
       ClientHeight    =   4245
       ClientLeft      =   60
       ClientTop       =   345
       ClientWidth     =   6210
       LinkTopic       =   "Form1"
       ScaleHeight     =   4245
       ScaleWidth      =   6210
       StartUpPosition =   3  '¨t²Î¹w³]­È
       Begin VB.ListBox List2
          Height          =   1860
          Left            =   3000
          TabIndex        =   3
          Top             =   840
          Width           =   2895
       End
       Begin VB.ListBox List1
          Height          =   1860
          Left            =   240
          TabIndex        =   0
          Top             =   840
          Width           =   2535
       End
       Begin VB.Label Label6
          BackColor       =   &H80000009&
          BorderStyle     =   1  '³æ½u©T©w
          Height          =   375
          Left            =   4200
          TabIndex        =   7
          Top             =   3600
          Width           =   1695
       End
       Begin VB.Label Label5
          Caption         =   "¯È±i°ª«×(³æ¦ì Âç¦Ì)"
          Height          =   375
          Left            =   4200
          TabIndex        =   6
          Top             =   3000
          Width           =   1695
       End
       Begin VB.Label Label4
          BackColor       =   &H80000009&
          BorderStyle     =   1  '³æ½u©T©w
          Height          =   375
          Left            =   2160
          TabIndex        =   5
          Top             =   3600
          Width           =   1695
       End
       Begin VB.Label Label3
          Caption         =   "¯È±i¼e«×(³æ¦ì Âç¦Ì)"
          Height          =   375
          Left            =   2160
          TabIndex        =   4
          Top             =   3000
          Width           =   1695
       End
       Begin VB.Label Label2
          Alignment       =   2  '¾a¤¤¹ï»ô
          Caption         =   "¥i¨Ï¥Î¯È±i®æ¦¡"
          Height          =   375
          Left            =   3360
          TabIndex        =   2
          Top             =   240
          Width           =   2175
       End
       Begin VB.Label Label1
          Alignment       =   2  '¾a¤¤¹ï»ô
          Caption         =   "¦Lªí¾÷«¬¸¹"
          Height          =   375
          Left            =   480
          TabIndex        =   1
          Top             =   240
          Width           =   2055
       End
    End
    Attribute VB_Name = "frmPrinterSet"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Option Explicit
    '©Ò¦³¯È±i«¬¸¹ªºÀx¦s°}¦C
    Dim PaperStyle(1 To 41) As String
    '¦Lªí¾÷°Ñ·ÓÅܼÆ
    Dim XPrint As Printer
    '§â©Ò¦³ Printer ª«¥ó¯à¤ä´©ªº¯È±i®æ¦¡»¡©ú©ñ¤J°}¦C¤¤
    Private Sub GotPaperStyle()
        PaperStyle(vbPRPSLetter) = "«Hºà¡A 8 1/2 x 11 ­^¦T¡C"
        PaperStyle(vbPRPSLetterSmall) = "¤p«¬«Hºà¡A 8 1/2 x 11 ­^¦T¡C"
        PaperStyle(vbPRPSTabloid) = "¤p«¬³ø¡A 11 x 17 ­^¦T¡C"
        PaperStyle(vbPRPSLedger) = "¤ÀÃþ±b¡A 17 x 11 ­^¦T¡C"
        PaperStyle(vbPRPSLegal) = "ªk«ßÀɮסA 8 1/2 x 14 ­^¦T¡C"
        PaperStyle(vbPRPSStatement) = "«Å§i®Ñ¡A5 1/2 x 8 1/2 ­^¦T¡C"
        PaperStyle(vbPRPSExecutive) = "¦æ¬FÀɮסA7 1/2 x 10 1/2 ­^¦T¡C"
        PaperStyle(vbPRPSA3) = "A3, 297 x 420 ¤½Íù"
        PaperStyle(vbPRPSA4) = "A4, 210 x 297 ¤½Íù"
        PaperStyle(vbPRPSA4Small) = "A4¤p¸¹¡A 210 x 297 ¤½Íù"
        PaperStyle(vbPRPSA5) = "A5, 148 x 210 ¤½Íù"
        PaperStyle(vbPRPSB4) = "B4, 250 x 354 ¤½Íù"
        PaperStyle(vbPRPSB5) = "B5, 182 x 257 ¤½Íù"
        PaperStyle(vbPRPSFolio) = "¹ï¶}¥»¡A 8 1/2 x 13 ­^¦T¡C"
        PaperStyle(vbPRPSQuarto) = "¥|¶}¥»¡A 215 x 275 ¤½Íù¡C"
        PaperStyle(vbPRPS10x14) = "10 x 14 ­^¦T¡C"
        PaperStyle(vbPRPS11x17) = "11 x 17 ­^¦T¡C"
        PaperStyle(vbPRPSNote) = "«K±ø¡A8 1/2 x 11 ­^¦T¡C"
        PaperStyle(vbPRPSEnv9) = "#9 «H«Ê¡A 3 7/8 x 8 7/8 ­^¦T¡C"
        PaperStyle(vbPRPSEnv10) = "#10 «H«Ê¡A 4 1/8 x 9 1/2 ­^¦T¡C"
        PaperStyle(vbPRPSEnv11) = "#11 «H«Ê¡A 4 1/2 x 10 3/8 ­^¦T¡C"
        PaperStyle(vbPRPSEnv12) = "#12 «H«Ê¡A 4 1/2 x 11 ­^¦T¡C"
        PaperStyle(vbPRPSEnv14) = "#14 «H«Ê¡A 5 x 11 1/2 ­^¦T¡C"
        PaperStyle(vbPRPSCSheet) = "C ¤Ø¤o¤u§@³æ"
        PaperStyle(vbPRPSDSheet) = "D ¤Ø¤o¤u§@³æ"
        PaperStyle(vbPRPSESheet) = "E ¤Ø¤o¤u§@³æ"
        PaperStyle(vbPRPSEnvDL) = "DL «¬«H«Ê¡A 110 x 220 ¤½Íù"
        PaperStyle(vbPRPSEnvC3) = "C3 «¬«H«Ê¡A 324 x 458 ¤½Íù"
        PaperStyle(vbPRPSEnvC4) = "C4 «¬«H«Ê¡A 229 x 324 ¤½Íù"
        PaperStyle(vbPRPSEnvC5) = "C5 «¬«H«Ê¡A 162 x 229 ¤½Íù"
        PaperStyle(vbPRPSEnvC6) = "C6 «¬«H«Ê¡A 114 x 162 ¤½Íù"
        PaperStyle(vbPRPSEnvC65) = "C65 «¬«H«Ê¡A114 x 229 ¤½Íù"
        PaperStyle(vbPRPSEnvB4) = "B4 «¬«H«Ê¡A 250 x 353 ¤½Íù"
        PaperStyle(vbPRPSEnvB5) = "B5 «¬«H«Ê¡A176 x 250 ¤½Íù"
        PaperStyle(vbPRPSEnvB6) = "B6 «¬«H«Ê¡A 176 x 125 ¤½Íù"
        PaperStyle(vbPRPSEnvItaly) = "«H«Ê¡A 110 x 230 ¤½Íù"
        PaperStyle(vbPRPSEnvMonarch) = "«H«Ê¤j¤ý¡A 3 7/8 x 7 1/2 ­^¦T¡C"
        PaperStyle(vbPRPSEnvPersonal) = "«H«Ê¡A 3 5/8 x 6 1/2 ­^¦T¡C"
        PaperStyle(vbPRPSFanfoldUS) = "U.S. ¼Ð·Ç½Æ¼gï¡A 14 7/8 x 11 ­^¦T¡C"
        PaperStyle(vbPRPSFanfoldStdGerman) = "¼w°ê¼Ð·Ç½Æ¼gï¡A 8 1/2 x 12 ­^¦T¡C"
        PaperStyle(vbPRPSFanfoldLglGerman) = "¼w°êªk«ß½Æ¼gï¡A 8 1/2 x 13 ­^¦T¡C"
    End Sub
    Private Sub Form_Load()
    Dim TempPrint As Printer
        '¦C¥X¥»¾÷¥i¨Ï¥Îªº©Ò¦³¦Lªí¾÷
        For Each TempPrint In Printers
            List1.AddItem TempPrint.DeviceName
        Next

        '°õ¦æ§â¯È±i®æ¦¡»¡©ú©ñ¤J°}¦C¤¤ªº¦Û­q°Æµ{¦¡
        GotPaperStyle
    End Sub
    Private Sub List1_Click()
        '¨Ì List1 Item ³]©w DefaultPrinter¡A¨Ã¨Ì  DefaultPrinter §ä¥X¥i¤ä´©ªº¯È
    ±i®æ¦¡¡C
        If List1.ListIndex >= 0 Then
            '³]©w DefaultPrinter°Æµ{¦¡
            SetDefaultPrinter List1.List(List1.ListIndex)
            '§ä¥X¤ä´©¯È±i®æ¦¡°Æµ{¦¡
            WhatPaperCanUse
        End If
    End Sub
    '³]©w DefaultPrinter°Æµ{¦¡
    Private Sub SetDefaultPrinter(ByVal DName As String)
        For Each XPrint In Printers
            If XPrint.DeviceName = DName Then
                Set Printer = XPrint
                Exit For
            End If
        Next
    End Sub
    '§ä¥X¤ä´©¯È±i®æ¦¡°Æµ{¦¡
    Private Sub WhatPaperCanUse()
    Dim I As Long

        On Error Resume Next
        List2.Clear

        For I = LBound(PaperStyle) To UBound(PaperStyle)
            '²M°£¿ù»~½X
            Err.Number = 0
            '¥»µ{¦¡¬O¥ý³]©w¯È±i®æ¦¡¡A¦AÆ[¹î¬O§_¦³»~¡A¥u¦³µL¿ù»~ªÌ¤~¥[¤J List2 ¤¤
            Printer.PaperSize = I
            Select Case Err.Number
                Case 0
                    List2.AddItem PaperStyle(I)
                    List2.ItemData(List2.NewIndex) = I
                Case 380
                Case Else
                    MsgBox Err.Description, vbOKOnly, "¿ù»~¥N¸¹¡G" & Err.Number
                    Exit For
            End Select
        Next
    End Sub
    '¨Ì¯È±i®æ¦¡Åã¥Ü¯È±iªø¼e
    Private Sub List2_Click()
        If List2.ListIndex >= 0 Then
            Printer.PaperSize = List2.ItemData(List2.ListIndex)
            Label4.Caption = Printer.ScaleX(Printer.Width, Printer.ScaleMode,vbMillimeters)
            Label6.Caption = Printer.ScaleY(Printer.Height, Printer.ScaleMode,vbMillimeters)
            '¦]¬°¤£­n¦L¥X¡A©Ò¥H§â¦C¦L§Ç¦C±þ±¼¡C
            Printer.KillDoc
        End If
    End Sub
    '--------------------  ¦Lªí¾÷³]©w½d¨Òµ²§ô  --------------------------

¦^¯Á¤Þ


¨ú±o BMP ¹Ï§ÎÃC¦â¼Æ


Option Explicit
Private Type BITMAPINFOHEADER '40 bytes
    biSize            As Long
    biWidth           As Long
    biHeight          As Long
    biPlanes          As Integer
    biBitCount        As Integer
    biCompression     As Long
    biSizeImage       As Long
    biXPelsPerMeter   As Long
    biYPelsPerMeter   As Long
    biClrUsed         As Long
    biClrImportant    As Long
  End Type
 
  Private Type BITMAPFILEHEADER
    bfType            As Integer
    bfSize            As Long
    bfReserved1       As Integer
    bfReserved2       As Integer
    bfOffBits         As Long
  End Type

Private Sub Command1_Click()
   Dim FileName As String
   Dim ff As Integer
   Dim FileHeader As BITMAPFILEHEADER
   Dim InfoHeader As BITMAPINFOHEADER
  
   FileName = "h:\delete.bmp"
 
   'read the file header info
   ff = FreeFile
   Open FileName For Binary Access Read As #ff
      Get #ff, , FileHeader
      Get #ff, , InfoHeader
   Close #ff
 
   MsgBox InfoHeader.biBitCount & " (" & 2 ^ InfoHeader.biBitCount & "
colours)"

End Sub

¦Ñ©Çªþµù¡G
¥u¯à¾A¥Î BMP ¹ÏÀÉ¡A¨ä¥L®æ¦¡¹ÏÀÉ·|²£¥Íµ{¦¡¿ù»~¡C

¦^¯Á¤Þ


¤@¤j¹Ï¤Á¦¨¼Æ¤p¹Ï


Tako _ ¼¶¼g©ó¤å³¹

½Ð°Ý¦bVB¤UŪ¤J¤@­ÓBMPÀÉ,¦p¦ó§â¥¦¤Á¦¨4x4­Ópictureª«¥ó©O?? ¬O»¡¤@­Ó800x600ªºbmpÀÉ.. ­n¤Á¦¨50x37ªº16­Ópictureª«¥ó...¦³¿ìªk¶Ü??

¦Ñ©Çµª¡G

'½d¨Ò¥\¯à¡G¤@¤j¹Ï¤Á¦¨¼Æ¤p¹Ï
'´ú¸Õ¥»½d¨Ò½Ð©óªí³æ¥¬¸m Text1(0),Text1(1),Picture1,Picture2
Option Explicit

Private Sub Command1_Click()
Dim XNum As Integer, YNum As Integer
Dim I As Integer, J As Integer
Dim PWidth As Single, PHeight As Single

    '§â Text ¤º®eÂন¤p¹ÏÁa¾î¤Á³Î¼Æ
    XNum = Val(Text1(0).Text)
    YNum = Val(Text1(1).Text)

    '´«ºâ¨C¶ô¤p¹Ïªºªø¼e
    With Picture1
        PWidth = .ScaleWidth / XNum
        PHeight = .ScaleHeight / YNum
    End With

    '¨Ì¤p¹Ïªø¼e¨M©w Picture2 ªø¼e
    With Picture2
        .Width = PWidth + .Width - .ScaleWidth
        .Height = PHeight + .Height - .ScaleHeight
    End With

    '§â Picture1 ¹Ï¤ù¤@¤p¶ô¤@¤p¶ô¶K¨ì Picture2 ¤W¡A¦A§â Picture2.Image ¦s
ÀÉ¡C
    For I = 0 To YNum - 1
        For J = 0 To XNum - 1
            With Picture2
                .AutoRedraw = True
                .PaintPicture Picture1.Picture, .ScaleLeft, .ScaleTop, , _
                        , J * PWidth, I * PHeight, .ScaleWidth, .ScaleHeight
                .AutoRedraw = False
                SavePicture .Image, "c:\test\" & Right(String(3, "0") _
                        & Trim(Val(I)) & Trim(Val(J)), 3) & ".bmp"
            End With
        Next
    Next
End Sub

Private Sub Form_Load()
    Picture1.AutoSize = True
    Picture2.Visible = False

    Text1(0).Text = ""
    Text1(1).Text = ""

    Picture1.Picture = LoadPicture("c:\temp\a18a.jpg")
End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
    'KeyAscii 32 ¥H¤U¬O¤@¨Ç±±¨îÁä¡AÄdºI·|³y¦¨¾Þ§@»Ùê
    If KeyAscii >= 33 Then
        If KeyAscii <= vbKey9 And KeyAscii >= vbKey0 Then
        Else
            '§â KeyAscii ³]¬° 0 ´N¬O¨ú®ø¿é¤J
            KeyAscii = 0
            MsgBox "¤£¥i¿é¤J«D¼Æ¦r¦r¤¸"
        End If
    End If
End Sub

¦^¯Á¤Þ


¦p¦ó§@¥iÂI¿ïÃC¦âªº Property


yclin ¼¶¼g©ó¤å³¹

½Ð°Ý¥HVB»s§@OCX, ¨äProperty ¤¤¦p¦ó¥X²{backcolor³oproperty(¥iÂI¿ïÃC¦â)?

¦Ñ©Çµª¡G

·í§A§â BackColor ¶Ç¤J¤Î¶Ç¦^­È³]¬° OLE_COLOR ´N¥i¥H¦bÄݩʵ¡ÂI¿ïÃC¦â¡C¦p¤U¨Ò¡G
Public Property Get BackColor() As OLE_COLOR
    BackColor = UserControl.BackColor
End Property

Public Property Let BackColor(ByVal New_BackColor As OLE_COLOR)
    UserControl.BackColor() = New_BackColor
    PropertyChanged "BackColor"
End Property

¦^¯Á¤Þ


¦A½× PaintPicture ªº³B²z°Ê§@


§Ú³ºµM¬O¤p§b¥Ê)

Picture1¨S¦³¸ü¤J¹Ï§Î
Picture1.PaintPicture Picture2,1,1,,,,,,vbSrcCopy
Form1.PaintPicture Picture1,1,1,,,,,,vbSrcCopy
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
µ²ªG¦³Error¡HPaintPicture¥u¯à§â¹Ïµe¦bª«¥ó¤W¦Ó¤£¯à¯u¥¿¼g¤Jª«¥ó¶Ü!?

¦Ñ©Çµª¡G

§Ú²¤Æ¤@¨Ç¨Ó»¡§a¡A§A¥i¥H§â VB ø¹Ï¤¸¥ó¬Ý¦¨¬O¦³¤T¼h­±ª©¡A©³¼hºÙ°µ Picture¼h¡A¤¤¼h¥s°µ Image ¼h¡A¦Ó¤W¼h¥s°µ Paint Show ¼h¡A©Ò¦³Ã¸¹Ï¤èªkLine,Circle,PaintPicture,Cls µ¥¡Aµe¥X¨Óªº¼v¹³³£¬O¦b Paint Show ¼h¤W¡A¦Ü©ó¥ÎLoadPicture or Set Object.Picture=PictureObject ªº¹Ï§Î¡A«h¬O©ñ¦b Picture ¼h¤W¡C

°ò¥»¤W Paint Show ¼hªº¼v¹³¬OµLªk³Q«ü©w©ÎÂ^¨úªº¡A¤]´N¬O»¡Ã¸¹Ï¤èªkLine,Circle,PaintPicture,Cls µ¥Ã¸¥Xªº¹Ï§Î¡A¥u¨ÑÅã¥Ü¥Î¡A·í§Aªº Form ³Q¨ä¥LForm ¾B½ª«á¡A´N®ø¥¢¤£¨£¤F¡C¦Ó¥H¬°¥Îø¹Ï¤èªkLine,Circle,PaintPicture,Cls ¬Oµe¦b Picture ¼h¤W¡A¤]¬O¹ï VB ø¹Ï¤¸¥ó°Ê§@¤£¤F¸Ñ©Ò¦Ü¡C

¨º³o»ò»¡Ã¸¹Ï¤¸¥óªºÃ¸¹Ï¤èªkø¥Xªº¹Ï«ç¼Ë¤~¯à³Q«ü©w©ÎÂ^¨ú©O¡A¨º´N¬O Image ¼hªº°µ¥Î¤F¡CImage ¼hªººc¦¨¬O¥¦­º¥ý·|§â Picture ¼h¼v¹³½Æ»s¤@¥÷·í©³(¡°ª`·N¡I´Nºâ Object.Picture ¥¼¸ü¤J©Î«ü©w¹Ï§Î¡AImage ¤@¼Ë¦³·N¸q¡A¦]¬°³o®É¥¦·|¥Hø¹Ïª«¥óªº BackColor ¬° Image¡C)µM«á·|¨Ìø¹Ïª«¥óªº AutoRedraw ª¬ªp¨M©wø¹Ï¤èªk¬O§_·|§â¹Ï§Îµe¨ì Image ¤W¡CAutoRedraw=False ®É¡A¤£ºÞø¹Ï¤¸¥ó«ç»òµe¡AImage ³£¤£·|§ïÅÜ¡Aºû«ù­ì¨Óªº Picture ¼hªº Image ¡A¦ý¦pªG§â AutoRedraw=True ®É¡A«h©Ò¦³ªºÃ¸¹Ï¤èªk³£·|µe¨ì Image ¼h¤W¡A¦Ó»P­ì¦s¦bªº Picture Image µ²¦X¦b¤@°_¡C

©Ò¥H¦pªGø¹Ï¥Øªº¥u¬O Show µ¹¨Ï¥ÎªÌ¬Ý¡A¨º»ò AutoRedraw ÄÝ©Ê¥i¥Hºû«ù Default ªº False ­È¡A¦ý¦pªGµe§¹«á­n«ü©wµ¹¨ä¥Lªºª«¥ó or SavePicture ¡A«h¤@©w­n AutoRedraw= True¡C

OK ¡A³Ì«áÁ`¾ã²z¡G

  1. §A­n¦bø¹Ï¤¸¥ó¤Wµe¹Ï§Î«á«ü©wµ¹¨ä¥Lª«¥ó©ÎÀx¦s¹ÏÀÉ¡C
  2. Åý¸Óø¹Ï¤¸¥óªº AutoRedraw=True¡C
  3. ¥Îø¹Ï¤èªk¦bø¹Ï¤¸¥ó¤Wø¹Ï¡C
  4. §â ø¹Ï¤¸¥ó.Image «ü©wµ¹²Ä¤G­Óª«¥ó©ÎÀx¦s¡A¦pªG¥H§b¥Êªº°ÝÃD´N¬O¡G
    Picture2.PaintPicture Picture1.Image

¦^¯Á¤Þ


²©ö¤ô¤¤­Ë¼v¸Õ°µ


'¥»½d¨Ò¬O¥Î VB PictureBox ª«¥ó¼ÒÀÀ±`¦b Java Applet ¥X²{ªº¤ô¤¤­Ë¼vª«¥ó®ÄªG¡A
'­ì²z¬O§â PictureBox ¤¤ªº¹Ï¤ù¬Ý°µ¬O±½ºË½uªº¶°¦X¡AµM«á§Q¥Î Timer ª«¥ó°t¦X
'For ... Next °j°é¡A¤@±ø¤@±ø·h¨ì¥t¤@­Ó PictureBox ùØ¡A¤£¹L·hªº¹Lµ{¤¤­n§â¥¦
'¦V¥ª¦V¥k²¾¤@¤U¡A´N¦³ªi¼vÀúºyªº·Pı¡C
'´ú¸Õ¥»½d¨Ò½Ð©óªí³æ¤W¥¬¸m Picture1,2¡BCommand1¡BTimer1¡C
Option Explicit
'¨M©w¥ª¥kªi¤j¤p
Private Const ¤ô¥­°¾²¾­È As Integer = 5
'¨M©w¹Ï½u¥ª²¾©Î¥k²¾ªº«ü¼Ð
Dim TurnBackA As Long, TurnBackB As Long
Private Sub Command1_Click()
    If Command1.Caption = "¶}©l­Ë¼v" Then
        With Picture2
            .PaintPicture Picture1.Picture, .ScaleLeft, .ScaleTop
        End With
        Timer1.Enabled = True
        Command1.Caption = "µ²§ô­Ë¼v"
    Else
        Timer1.Enabled = False
        Picture2.Cls
        Command1.Caption = "¶}©l­Ë¼v"
    End If
End Sub
Private Sub Form_Load()
    '¥¬¸m¦U±±¨î¶µ¦ì¸m¤Î¤j¤p
    With Picture1
        Picture2.ScaleMode = 3
        .ScaleMode = 3
        .AutoSize = True
        .Picture = LoadPicture("c:\temp\sisbkgnd.bmp")
        .Move Me.ScaleLeft, .ScaleTop
        Picture2.Move Me.ScaleLeft, Me.ScaleTop + .Height, .Width, .Height

        Me.Width = .Width + Me.Width - Me.ScaleWidth
        Me.Height = .Height * 2 + Command1.Height + 240 + _
                Me.Height - Me.ScaleHeight
        Me.Caption = "VB ¤ô¤¤­Ë¼v½d¨Ò"

        Command1.Move (Me.ScaleWidth - Command1.Width) / 2, .Height * 2 +
120
        Command1.Caption = "¶}©l­Ë¼v"
    End With

    With Timer1
        .Enabled = False
        .Interval = 66
    End With

    '¥ý³]©wªi¯¾¥k²¾
    TurnBackA = 1
    TurnBackB = 1
End Sub
Private Sub Timer1_Timer()
'²Ä¤@±ø½uªº¥ª¥k²¾°Ê¶q
Static OffStart As Long
'¨C±ø¹Ï½u¥ª¥k²¾°Ê¶q
Static Offset As Long
Dim I As Long
    With Picture2
        TurnBackA = 1 * TurnBackB
        '³vÂI¶K¤W¹Ï½uªº°j°é
        For I = 0 To .ScaleHeight - 1
            .PaintPicture Picture1.Picture, Offset, I, .Width, 1, _
                    0, I, .Width, 1
            If Abs(Offset) = ¤ô¥­°¾²¾­È Then
                Offset = 0
                TurnBackA = TurnBackA * -1
            Else
                Offset = Offset + (1 * TurnBackA)
            End If
            DoEvents
        Next
    End With

    If Abs(OffStart) = ¤ô¥­°¾²¾­È Then
        OffStart = 0
        TurnBackB = TurnBackB * -1
    Else
        OffStart = OffStart + (1 * TurnBackB)
    End If

    Offset = OffStart
End Sub

¦^¯Á¤Þ


Form Unload «áÅܼƦû¥Î°O¾ÐÅ骬ªp


hear ¼¶¼g©ó¤å³¹

·PÁ¤j®a¼ö¤ßªº¦^µª. °O¾ÐÅ骺±±¨î¹ê¦b¬Oµ{¦¡¼g§@«Ü­«­nªº³¡¤À, ±±¨î±o¦n, ¸ê·½¤~¯à¦³®Ä§Q¥Î, µ{¦¡®Ä¯à¤]¤~¯àµo´§..§Ú¹ïCOM¨Ã¤£¼ô±x, ®Ú¾Ú¦U¦ìªº¦^µª, ¾ã²z¦p¤U, ¤£ª¾¹D¦³¨S¦³¿ù»~:Form Unload¤§«á, ·|ÄÀ©ñForm¤º³¡Public»PPrivateªºÅܼưO¾ÐÅéªÅ¶¡,

¤£¬O³o¼Ëªº¡A

  1. ©Ò¦³¦b Form ¤@¯ë°ÏùثŧiªºÅܼơA¤£½×¬OPublic or Private ³£¤£·|³QÄÀ©ñ¡A¦b°Æµ{§Çùتº Static ¤]¤£·|³QÄÀ©ñ¡A¥u¦³¦b°Æµ{¦¡ùتº Private ¤~·|³QÄÀ©ñ¡C¦b Form ¤W©ñ³o¬q¦A§â¥¦ Load ,Unload ´N¥i¥H¦b Debug Windows ¤W¬Ý¥X¨Ó¡C
    Option Explicit

    Public Fa As Integer
    Private Fb As Integer

    Private Sub Command1_Click()
    Dim Fc As Integer
    Static Fd As Integer

        Fa = Fa + 1
        Fb = Fb + 1
        Fc = Fc + 1
        Fd = Fd + 1

        Debug.Print "Fa:" & Fa
        Debug.Print "Fb:" & Fb
        Debug.Print "Fc:" & Fc
        Debug.Print "Fd:" & Fd
    End Sub
  2. ¦ÓForm Terminate¤§«á, Form¥»¨­(ÄÝ©Ê, ¤èªk...)©Ò¦ûªºªÅ¶¡ÄÀ©ñ±¡ªp¦p¤U¡G
  3. ¬Û¤Ïªº¬O Form ¤ºªº Control.Propperty ¡A¦b°õ¦æ¶¥¬q¥[¥H§ïÅÜ¡A«h Unload «á¡A¸ê®Æ§Y®ø¥¢¡C

¦^¯Á¤Þ


ªø®É¶¡±Æµ{³qª¾


b8740038¼¶¼g©ó¤å³¹

§Ú­n¨C3¤p®É°õ¦æ¤@­Óµ{§Ç¡A°£¤F¨Ï¥ÎTIMER¥~,ÁÙ¦³Ô£¤èªk??¦pªG¥ÎTIMER±±¨î¶µ¤£´N­n¨Ï¥Î3­Ó??¦]¬°,¤@­ÓTIMERªºINTERVAL³Ì¦h¥u¦³1MINS¦h???

¦Ñ©Çµª¡G

«ô°U¡A¨º¦pªG§A­n¬Y¦~¬Y¤ëªº¬Y¤@¤Ñ«ç»ò¿ì¡H¨C¬íÀˬd¤@¦¸¹L¤F¤T­Ó¤p®É¨S¡A´N³o¼Ë¡C

Dim Startime As Date

Sub Form_Load()
    Startime=Now()
    Timer1.Interval=1000
End Sub

Sub Timer1_Timer()
    If Hour(Now-Startime)>=3 Then
        MsgBox "¹L¤F¤T¤p®É"
        Startime=Now()
    End If
End Sub

¦^¯Á¤Þ


¦P®É©T©wªí³æ¤ÎÅã¥Ü³Ì¤p¤Æ«ö¶s


%­«·s·Pı©¼¦¹% ¼¶¼g©ó¤å³¹

¦bvbªºªí³æ¤¤·|¥X²{¥k¤W¨¤¤T­Ó«ö¶sªºÄݩʦn¹³¥u¦³ BorderStyle=2®É,¨ä¥Lªº(=0,1,3,4,5)³£¥u¦³x or nothing,     µM¦ÓBorderStyle=2®É,ªí³æ¤j¤p¤S¥i¥Î·Æ¹«©ì©ÔÃä¬É©ñ¤jÁY¤p¡C½Ð°Ý§Ú­n«ç»ò³]©w¤~¯à°µ¨ì ¤S¥i¨Ï¥Î³Ì¤p¤Æ«ö¶s¤S¥i©T©wÃä¬É ·Æ¹«¤£¯à©ì©ÔÃä¬É§ïÅܪí³æ¤j¤p???

¦Ñ©Çµª¡G

  1. Form.BorderStyle=1(³æ½u©T©w)
  2. Form.MinButon=True

¦^¯Á¤Þ


¥Îª«¥ó¦WºÙ¦r¦ê¾Þ§@ª«¥ó


  1. ¥Îª«¥ó¦WºÙ¦r¦ê¾Þ§@ª«¥ó¡G
    Private Sub Command1_Click()
    Dim CtlName As String
        CtlName = "Text1"
        Me.Controls(CtlName).FontSize = 14
    End Sub
  2. ¥Îª«¥óÅܼưѷӾާ@ª«¥ó¡G
    Dim Ctl As Control
    Set Ctl=Text1
    Ctl.Text="ABCD"

¦^¯Á¤Þ


¨Ï¥Î·Æ¹«¥kÁä¥s¥X¿ï³æ


·Q°µ´N¥h°µ§a ¼¶¼g©ó¤å³¹

½Ð°Ý¦b¦p¦ó¦bVB¤¤¨Ï¥Î·Æ¹«¥kÁä¥s¥X¿ï³æ(menu)¡H§Ú§Æ±æ¤£­n¦b MenuLine ¤WÅã¥Ü¡A¥uÅý¨Ï¥ÎªÌ³z¹L·Æ¹«¥kÁä¨Ó°µ¿ï³æªº¿ï¾Ü¡C

¦Ñ©Çµª¡G

Option Explicit
Private Sub Form_Load()
    MenuName.Visible = False
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single,
Y As Single)
    If Button = 2 Then
        Me.PopupMenu MenuName
    End If
End Sub

¦^¯Á¤Þ


Åý Combo.AddItem ¤£­«ÂÐ


µæ³¾¤@ÂS¤â ¼¶¼g©ó¤å³¹

¦p¦ó¼g¤@­Óµ{¦¡Åý¬Û¦Pªºitem¥u¥X²{¤@¦¸,¦badditemªº¦P®É´N¶¶«KÀˬd¦³¨S¦³­«½Æªº,¨S¦³­«½Æªº¤~additem.¦³­«½Æªº´N¸õ¹L¡H

¦Ñ©Çµª¡G

Option Explicit
Private Sub Combo1_KeyPress(KeyAscii As Integer)
Dim I As Long
Dim Duplicate As Boolean
    'À£¤U Enter ªí¥Ü¿é¤J§¹²¦
    If KeyAscii = 13 Then
        '³]©w¿é¤J¥¼­«Âйw³]­È
        Duplicate = False
        If Combo1.ListCount = 0 Then
            Combo1.AddItem Combo1.Text
        Else
            'Àˬd©Ò¦³¿é¤J°O¿ý¬O§_­«ÂÐ
            For I = 0 To Combo1.ListCount - 1
                If Combo1.List(I) = Combo1.Text Then
                    Duplicate = True
                    MsgBox "¿é¤J¶µ­«½Æ"
                    Exit For
                End If
            Next
            '¦pªG¤£­«ÂФ~¥[¤J¸Ó¶µ
            If Not Duplicate Then
                Combo1.AddItem Combo1.Text
            End If
        End If
    End If
End Sub

¦^¯Á¤Þ


¦^­º­¶

1