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

¦^­º­¶


¤ÀÃþ

¼ÐÃD

¤j·N

§@ªÌ

¤é´Á

µ{¦¡¥æ´« ¦b VB ùذõ¦æ Dos ¤º«Ø©R¥O ¡@ ¤pà© 1998/6/29
ÀÉ®×I/O ¤G¶i¦ìÀɽƻs For Binary ¡@ ¡@
ÀÉ®×I/O ¨âÀɦX¨Ö¦¨¤@ÀÉ ¡@ ¦Ñ©Ç 1998/7/8
ÀÉ®×I/O °O¿ý¹q¸£¶}¾÷®É¶¡ ¡@ ¦Ñ©Ç 1998/8/11
ª«¥ó¥Îªk StdPicture ªº Scale ´«ºâ vbHimetric »P Twip ¤p¿« 1998/7/4
ª«¥ó¥Îªk ¦C¦L¦V¥k¹ï»ô Printer ª«¥óªº¨Ï¥Î ¦Ñ©Ç ¡@
ª«¥ó¥Îªk VB ªº±m¦â¤å¦r¦C¦L Printer.ColorMode ªº¨Ï¥Î ¦Ñ©Ç 1998/8/1
ª«¥ó¥Îªk ÅX°Ê¦Lªí¾÷ªº°ò¥»«ü¥O Printer ª«¥óªº¨Ï¥Î ¦Ñ©Ç 1998/8/9
¬yµ{±±¨î ¤ñ Timer §óºë½Tªº­p®É §â Time Á٭즨 Double «¬ºA ¦Ñ©Ç 1998/7/14
¬yµ{±±¨î ¤@­Ó²³æªº¶i«×ªí ¡@ ¦Ñ©Ç 1998/8/10
¤¸¥ó¥Îªk ¦b TextBox ùتº´«¦æ ´«¦æ¦r¤¸ªº¨Ï¥Î ¦Ñ©Ç 1998/8/1
¬É­±¥~Æ[ ÀH¤ß©Ò±ýªº¾î¦C»PÁa¦C °}¦C¤¸¥óªº Align ¦Ñ©Ç 1998/7/16
¬É­±¥~Æ[ ¥­¶¶ªºÁä½L²¾°Ê Â\²æÁä½L¦^À³³t²vªº¿ìªk ¦Ñ©Ç 1998/8/10
¬É­±¥~Æ[ ³sµoªº·Æ¹««öÁä Åý·Æ¹«¤Þµo³sÄòªº¨Æ¥ó ¦Ñ©Ç 1998/8/11
¤¤¤å³B²z ¦p¦ó§â¤¤¤å¤º½XÂন¤¤¤å ¤£­n§â VB ·í­Ê¤Ñ ¦Ñ©Ç 1998/7/17
ÅܼƳB²z ¥Î Array() «Å§i¦hºûÅÜ¼Æ Collection «¬ºAªºÅÜ¼Æ ¦Ñ©Ç 1998/8/3
ÅܼƳB²z Åܼƫŧiªº¦w¥þ°ÝÃD ¦h¤Hµ{¦¡¶}µoªºª`·N¨Æ¶µ ¦Ñ©Ç 1998/8/8
ÅܼƳB²z ÅܼƭȮø¥¢¤F ¤£¦PªºÅܼơA¬Û¦Pªº¦WºÙ¡C ¦Ñ©Ç 1998/8/9
¥j©Ç³B²z ¤£¸Ó·¸¦ìªº·¸¦ì ¡@ ¦Ñ©Ç 1998/8/9
¥j©Ç³B²z µLªk¦b With °Ï¶ô¤¤°õ¦æªº°Ê§@ ¡@ ¦Ñ©Ç 1998/8/11

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©Ò¦³¨Ã¨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

¦^¯Á¤Þ


¦b VB ùذõ¦æ Dos ¤º«Ø©R¥O


±H¥óªÌ: ¤pà©

§Ú·|¥Î shell °õ¦æ dos «ü¥O¤F¡A¦pªG­n dir or cls ....shell("command.com /c dir")´N¥i¥H¤F.... ¬Æ¦Ü©ó copy ¤]¥i¥H.....¸Õ¤F¦n¤[...¯u²Ö

¦Ñ©Çµª¡G

  1. command /c °õ¦æ§¹µe­±·|¥ß¨èµ²§ô
  2. command /k «h·|°±¦b¨º¸Ì
  3. °Ñ¼Æªº¤Uªk¥Î command /?
  4. ±©¤@ªº¿ò¾Ñ¬O SendKeys ¤´¬OµLªk°e¨ì«D windows µ{¦¡ùØ¡C
  5. ·PÁ¤p੪º°í«ù»P§V¤O¡A¨Ï§Ú¨ü¯q¨}¦h¡C

¦^¯Á¤Þ


¤G¶i¦ìÀɽƻs


Dim Buff() As Byte   '³]©w¤@­Ó Byte«¬§Oªº°}¦C
    Open "C:\temp\TestA.exe" For Binary As #1  ' ¶}±Ò­ì©lÀÉ®×
    ReDim Buff(LOF(1) - 1)  '­«·s³]©w°}¦C¤j¤p
    Get #1, , Buff()
    Close #1       'Ãö³¬ÀÉ®×

    Open "c:\temp\TestB.EXE" For Binary As #1
    Put #1, , Buff()    '±N TEMP()¤¤ªº¸ê®Æ¼g¨ìÀÉ®×½s¸¹1ªºÀÉ
    Close #1

¡°³o¬O±q¤@¦ì tw.bbs.comp.language ªº sonora ª©¤Íªºµ{¦¡§ï¼gªº ¡°

¦^¯Á¤Þ


StdPicture ªº Scale ´«ºâ


¦Ñ©Ç ¦b programming ª©´£¨ì:

½Ð°Ý¦³¨º¦ì°ª¤âª¾¹D¡AStdPicture ªº Width ©M Height ­n«ç¼Ë¸ò twip ´«ºâ¡C

¤p¿«µª¡G

  1. StdPicture ªº Scalemode ¬O vbHimetric
  2. ScaleX(MyPic.Width, vbHimetric, vbTwips) '¬O MyPic ªº Twip Width
  3. ScaleY(MyPic.Height, vbHimetric, vbTwips) '¬O MyPic ªº Twip Height

¦^¯Á¤Þ


¨âÀɦX¨Ö¦¨¤@ÀÉ


·R¼wµØ ¼¶¼g©ó¤å³¹

½Ð°Ý¦U¦ì¡A¦³¤°»ò¤èªk¥i¥H¦p COPY A+B=Cªº¤è¦¡¥ÎVB±N¨â­ÓÀɮ׬ۥ[ ?

¦Ñ©Çµª¡G

Dim GetHandle As Integer, PutHandle
Dim Buff() As Byte

    '¶}¦X¨ÖÀÉ C.txt
    PutHandle = FreeFile
    Open "c:\test\c.txt" For Binary Access Write As #PutHandle

    '¶}¨Ó·½ÀÉ A.txt
    GetHandle = FreeFile
    Open "c:\test\a.txt" For Binary Access Read As #GetHandle
    ReDim Buff(LOF(GetHandle) + 1)

    '¥Î Buff ¨ú±o¸ê®Æ
    Get #GetHandle, , Buff
    Close #GetHandle

    '¥[¤W´«¦æ¤ÎÂk¦ì¦r¤¸
    Buff(UBound(Buff) - 1) = 13
    Buff(UBound(Buff)) = 10

    '©ñ¨ì C.txt ùØ
    Put #PutHandle, , Buff

    '¶}¨Ó·½ÀÉ B.txt
    GetHandle = FreeFile
    Open "c:\test\b.txt" For Binary Access Read As #GetHandle
    ReDim Buff(LOF(GetHandle) - 1)

    '¥Î Buff ¨ú±o¸ê®Æ
    Get #GetHandle, , Buff
    Close #GetHandle

    '©ñ¨ì C.txt ùØ
    Put #PutHandle, , Buff

    'Ãö±¼¦X¨ÖÀÉ
    Close #PutHandle
End Sub

¦^¯Á¤Þ


¤ñ Timer §óºë½Tªº­p®É


Bonjour ¼¶¼g©ó¤å³¹

¦pªG­n­pºâ¨ì¤ñ¤d¤À¤§¤@¬í¤pªº®É¶¡,­n«ç¼Ë°µ©O??

¦Ñ©Çµª¡G

Option Explicit

'ºë±K­p®É¾¹¨ç¼Æ¡A¥i¶Ç¦^ ®É¡B¤À¡B¬í¤Î ¬í¤U¥|¦ì¼Æ
Private Function MiniTimer(ByVal FTime As Double, ByVal STime As Double)
Dim ReArray(3) As Integer
Dim CalcTime As Double

CalcTime = STime - FTime
ReArray(0) = Hour(CalcTime)
ReArray(1) = Minute(CalcTime)
ReArray(2) = Second(CalcTime)

'§â¤é®É¤À¬í¥h±¼
CalcTime = CalcTime * 100000
CalcTime = CalcTime - Int(CalcTime)

'¬í¤U¨ú¥|­Ó¼Æ¦r,¨ä¾l¤£¥Î
CalcTime = CalcTime * 10000
CalcTime = Int(CalcTime)

ReArray(3) = CalcTime

MiniTimer = ReArray
End Function

Private Sub Form_Click()
Dim varAccept As Variant
Dim ATime As Double, BTime As Double
Dim I As Long

Me.MousePointer = 11

ATime = Now

For I = 0 To 10000000
Next

BTime = Now

varAccept = MiniTimer(ATime, BTime)

Print "®É ¡G" & varAccept(0)
Print "¤À ¡G" & varAccept(1)
Print "¬í ¡G" & varAccept(2)
Print "·L¬í¡G" & varAccept(3)

Me.MousePointer = 0
End Sub

³]­pªº­ì²z¬O VB ªº Date «¬ºA¡A¨ä¹ê´N¬O Double «¬ºA¡A¥¦¬O¥Î¾ã¼Æ¤­¦ì¥Nªí¦~¤ë¤é¡A¤p¼Æ¤­¦ì¥Nªí®É¤À¬í¡A¤p¼Æ¥H«á§óºë·Lªº¼Æ¦r¥¦´N¤£ºÞ¤F¡C¦]¦¹¾e¨ú¤p¼Æ¤­¦ì¥H«áªº¼Æ¦r¡AÀ³¸Ó´N¬O¤ñ¬í§ó¤pªº­p¼Æ¤F¡C¦Ü©ó¦¹ºØ¶Ç¦^­È¬O§_¯uªººë·Ç¤Î¦³¹ê½è¤Wªº·N¸q¡A½Ð°ª¤â¬Ý¨ì¦¹½g®É¡A¶}¾É§Ú¤@¤U¡C

¦^¯Á¤Þ


¦C¦L¦V¥k¹ï»ô


simonsays ¼¶¼g©ó¤å³¹

vb¦C¦L³øªí½Ð°Ý¦p¦ó¾a¥k¹ï»ô

¦Ñ©Çµª¡G

'«Å§i¦C¦L¦r¦ê
Dim PrintString As String
'«Å§i¦C¦L¦r¦ê¼e«×
Dim StrWidth As Single

    '§A­n¿é¥Xªº¦r¦ê
    PrintString = "You can say something"

    '­pºâ¦r¦ê¼e«×
    StrWidth = Printer.TextWidth(PrintString)

    '³]©w¦L¦rÀY¾î¦V¦ì¸m
    Printer.CurrentX = Printer.ScaleWidth - StrWidth

    '¦Lªí¾÷¦L¥X¸Ó¦r¦ê
    Printer.Print PrintString

¦^¯Á¤Þ


ÀH¤ß©Ò±ýªº¾î¦C»PÁa¦C


¤p½÷ ¼¶¼g©ó¤å³¹

²{¦b§Ú¦³ 10 ­Óª«¥ó ex: button¡A·Q¥Îµ{¦¡Åý¥¦¦³®Éª½ªº±Æ¤@¦C¡A¦³®É¾îªº¤@¦C·Q½Ð°Ý¤@¤U³o¦³¥i¯à¶Ü???????

¦Ñ©Çµª¡G

·íµM¥i¥H¡A©³¤U¬O Command Button Áa¾î¤j¾\§L¸Õ§@¡G

'§â³o¤@¬q¶K¨ì°O¨Æ¥»¡A°ÆÀɦW¦s¦¨ .frm ¡A
'´N¬O VB ªº Form ÀÉ¡A¬Ù¥h¦Û¤vµe form¡C
'--------------- Cut Here ---------------------
VERSION 5.00
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   4800
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4815
   LinkTopic       =   "Form1"
   ScaleHeight     =   4800
   ScaleWidth      =   4815
   StartUpPosition =   3  '¨t²Î¹w³]­È
   Begin VB.CommandButton cmdAlign
      Caption         =   "¥k"
      BeginProperty Font
         Name            =   "·s²Ó©úÅé"
         Size            =   12
         Charset         =   136
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   3
      Left            =   2760
      TabIndex        =   4
      Top             =   2160
      Width           =   495
   End
   Begin VB.CommandButton cmdAlign
      Caption         =   "¥ª"
      BeginProperty Font
         Name            =   "·s²Ó©úÅé"
         Size            =   12
         Charset         =   136
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   2
      Left            =   1800
      TabIndex        =   3
      Top             =   2160
      Width           =   495
   End
   Begin VB.CommandButton cmdAlign
      Caption         =   "¤U"
      BeginProperty Font
         Name            =   "·s²Ó©úÅé"
         Size            =   12
         Charset         =   136
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   1
      Left            =   2280
      TabIndex        =   2
      Top             =   2640
      Width           =   495
   End
   Begin VB.CommandButton cmdAlign
      Caption         =   "¤W"
      BeginProperty Font
         Name            =   "·s²Ó©úÅé"
         Size            =   12
         Charset         =   136
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   0
      Left            =   2280
      TabIndex        =   1
      Top             =   1680
      Width           =   495
   End
   Begin VB.CommandButton cmdButton
      Caption         =   "1"
      BeginProperty Font
         Name            =   "·s²Ó©úÅé"
         Size            =   9.75
         Charset         =   136
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   495
      Index           =   0
      Left            =   720
      TabIndex        =   0
      Top             =   480
      Width           =   495
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'button °}¦C¶}©l±Æ¦C¦ì¸m
Dim XPos As Single, YPos As Single
'³]©w button ¤j¤pªºÅܼÆ
Dim cmdWide As Single
'³]©w¹ï»ôÃä¬Éªº¤è¦¡
Dim ButtonAlign As Integer
Private Sub cmdAlign_Click(Index As Integer)
    '¨Ì index ­È§ïÅÜ ButtonAlign ªº¤è¦¡
    ButtonAlign = Index + 1
    'IJµo Resize µ{§Ç
    Form_Resize
End Sub
Private Sub cmdButton_Click(Index As Integer)
    '¨SÔ£¤Ó¤j·N«ä¡A¦nª±¦Ó¤w¡C
    MsgBox "§Ú¬O [" + Trim(CStr(Index + 1)) + _
            "] ¸¹«ö¯Ã", vbOKOnly, "Button ¥\¯à"
End Sub

Private Sub Form_Load()
Dim I As Integer

    'Load 9 ­Ó Button ¶i¨Ó
    For I = 1 To 9
        Load cmdButton(I)
        '¨Ì¦¸µ¹©wÅã¥Ü­È
        cmdButton(I).Caption = Trim(CStr(I + 1))
        'load ¶i¨Óªºª«¥ó visible=false
        '­n visible=true ¤~¯à¬Ý¨£
        cmdButton(I).Visible = True
    Next

    '¥ý³]©w¹ï»ô¤è¦¡¬°¦V¤W¹ï»ô
    ButtonAlign = 1
End Sub

Private Sub Form_Resize()
    '­«·s³]©w button ¤j¤p,¨Ï¶ñº¡¾ã­ÓÃä¬É
    If ButtonAlign = 1 Or ButtonAlign = 2 Then
        cmdWide = Me.ScaleWidth / 10
    Else
        cmdWide = Me.ScaleHeight / 10
    End If

    '©I¥s§ïÅÜ button ¤j¤p Sub
    cmdResize
End Sub

'§ïÅÜ button ¤j¤p Sub
Private Sub cmdResize()
Dim I As Integer
    For I = 0 To 9
        cmdButton(I).Width = cmdWide
        cmdButton(I).Height = cmdWide
    Next
    '©I¥s³]©w±Æ¦C­ìÂI Sub
    OrignXY
End Sub

'³]©w±Æ¦C­ìÂI Sub
Private Sub OrignXY()
    Select Case ButtonAlign
        '¦V¤W¹ï»ô
        Case 1
            XPos = Me.ScaleLeft
            YPos = Me.ScaleTop
            '©I¥s¾î±Æ Sub
            WPutButton
        '¦V¤U¹ï»ô
        Case 2
            XPos = Me.ScaleLeft
            YPos = Me.ScaleHeight - cmdWide
            '©I¥s¾î±Æ Sub
            WPutButton
        '¦V¥ª¹ï»ô
        Case 3
            XPos = Me.ScaleLeft
            YPos = Me.ScaleTop
            '©I¥sª½±Æ Sub
            HPutButton
        '¦V¥k¹ï»ô
        Case 4
            XPos = Me.ScaleWidth - cmdWide
            YPos = Me.ScaleTop
            '©I¥sª½±Æ Sub
            HPutButton
    End Select
End Sub

'¾î±Æ¨ç¼Æ
Private Sub WPutButton()
Dim I As Integer
    For I = 0 To 9
        '¤W¤U¦ì¸m¤£ÅÜ¡A¦V¥k»¼¼W
        cmdButton(I).Move I * cmdWide, YPos
    Next
End Sub

'ª½±Æ¨ç¼Æ
Private Sub HPutButton()
Dim I As Integer
    For I = 0 To 9
        '¥ª¥k¦ì¸m¤£ÅÜ¡A¦V¤U»¼¼W
        cmdButton(I).Move XPos, I * cmdWide
    Next
End Sub
'-----------   End Here   --------------------------------

¦^¯Á¤Þ


¦p¦ó§â¤¤¤å¤º½XÂন¤¤¤å


³s³s ¼¶¼g©ó¤å³¹

§Ú·Q§Q¥ÎChr()§â¤¤¤å¤º½XÂন¤¤¤å¦rÅã¥Ü¥X¨Ó¡G

  1. ¦p   ¤¤¤å¦rªº "³Ì"    ¥Lªº¤º½X¬OB3CC
  2. B3Âର10¶i¦ì¬O179
  3. CC  ¬O  204
  4. ¥i¬O Print Chr(179) + Chr(204)«o¤£¦æ¥X²{
  5. ©Î¬O A= Chr(179) + Chr(204) Print A ¤]³£¬OªÅ¥Õ¬O¤£¬O¦³¨ä¥Lªº³]©w­nª`·N?

¦Ñ©Çµª¡G

½Ð¤£­n§Ñ¤F VB ªº¼Ð·Ç¦r½X¬O Unicode ¡A¬O Two Byte ªº¦r½X¡A¤£»Ý­n¹³ Ansi(One Byte) ¤@¼Ë©î¶}¨Ó¦A¦X¤@°_¡A¦Ó¥B VB ¤£¤ä´© Chr(128)~Chr(255) ªº¦r½X¡A©Ò¥H¬OªÅ¥Õ¡C½Ðª½±µ Chr(&HB3CC) §Y¥i¡A¤U­±ªº¦¡¤l«h¦b¤º½XÂà´«¤¤«Ü¦³¥Î¡C

Dim PutCode As String

    PutCode = "B3CC"
    Print Chr("&H" + PutCode)

¦^¯Á¤Þ


VB ªº±m¦â¤å¦r¦C¦L


angel tear ¼¶¼g©ó¤å³¹

¦b Visual BASIC ¤¤¦p¦ó¥Î¦Lªí¾÷¦L¥X±m¦â¤å¦r¡H§Ú³]¤F Printer.ForeColor ÄݩʡA¦ý¬O¦L¥X¨Ó³£¬O¶Â¦â¤å¦r¡C

¦Ñ©Çµª¡G

  1. Printer.ColorMode [= value] ¶Ç¦^©Î³]©w¤@­Ó¼Æ­È¡A¥H¨M©w±m¦â¦Lªí¾÷¬O¥H±m¦â©Î³æ¦â¿é¥X¡C°õ¦æ¶¥¬qµLªk¨Ï¥Î¡C
  2. value ªº³]©w­È¬°¡G
  3. ½Ðª`·N¡G

¦^¯Á¤Þ


¦b TextBox ùتº´«¦æ


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

¦b¤@­Ó Multi-line `ªº Textbox ¤¤Åã¥Ü¦¨¨â¦æ?

¦Ñ©Çµª¡G

  1. Msg = String1 & chr(13) & chr(10) & String2
  2. Msg = String1 & vbCRLF & String2

¦^¯Á¤Þ


¥Î Array() «Å§i¦hºûÅܼÆ


¥Á­ô ¼¶¼g©ó¤å³¹

¦bVB5 ¤¤¥i¥ÎARRAY()¨Óµ¹°}¦Cªì©l­È,¦ý¥¦¦n¹³¥u¯à¥Î©ó¤@ºû, ¤£ª¾¦hºû°}¦C¦p¦óµ¹©wªì©l­È?

¦Ñ©Çµª¡G

  1. ³Ì°ò¥»ªº¥Îªk¡G
  2. ÅܤƥΪk(Âন°ÊºA°}¦C)¡G
    ¥Î Array()¨ç¼Æ«Å§i¥X¨Óªº°}¦C¡A¨ä¹ê¬O³Q¾A¥Î°ÊºA°}¦C³B²zªº¡C§A¥i¥H¦bµ{¦¡»Ý­nªº®É­Ô°µ MyArray ªººû¼Æ­««Å§i¡A¦p ReDim MyArray(4,5,6)¡A¥u¤£¹L³o®É¨ú¥X³]©w­Èªº¼gªk¤S¤£¦P¤F¡A¥¦À³¸Ó¬O MyArray(Index,Index,Index) ¡A¦Ó¤£¯à¬O MyArray(Index)(Index)(Index)¡C
  3. ¥t¤@­Ó¿ï¾Üªº¤è®×¡G
    '§A¥i¦Ò¼{¨Ï¥Î¶°¦XÅܼƫŧi¦p¤U¡G
    Dim Collect As Collection

    'µ¹©wªì­È
    Private Sub Form_Load()
    Dim itmVar As Variant

        Set Collect = New Collection
        itmVar = Array(1, 2, 3)
        Collect.Add itmVar
        itmVar = Array("My", "Your")
        Collect.Add itmVar
        itmVar = Array(#8/1/98#)
        Collect.Add itmVar
    End Sub

    '¨ú¥X¶°¦XÅܼÆùتº¤º®e­È
    Private Sub Command1_Click()
    Dim Check As Variant
    Dim I As Long

        For Each Check In Collect
            For I = 0 To UBound(Check)
                List1.AddItem Check(I)
            Next
        Next
    End Sub

    Collection «¬ºAÅܼƬO VB ùØ®e¨ü¤O³Ì°ªªºÅܼƫ¬ºA¡A½Ð¦h¾Ç²ß¦p¦ó¥[¤J¤º®e¤Î¨ú¥X¤º®e¡A¹ï±N¨Ó Class ¤Î ActiveX ªº¼¶¼g¡A¤]¬O¤£¥i©Î¯Êªº­«­n¥\¯à¡C

¦^¯Á¤Þ


Åܼƫŧiªº¦w¥þ°ÝÃD


¨«¹L¤@©uÀéÄê ¼¶¼g©ó¤å³¹

§Ú¦b¤@­Ó MDI Parent Form ¤¤ªº General ³¡¥÷«Å§i¤F¤@­Ó ¦r¦êÅÜ¼Æ ¡G

Public MyStr as String
Private Sub Form_Load()
MyStr = "ABCDE"
End Sub

¦ý¦b¥t¤@­Ó MDI Child Form ¤¤¨Ï¥Î MyStr ®É¥X¤F°ÝÃD  , MyStr ªº­È¥¢±¼¤F ,À³«ç¼Ë¼g¤~¹ï ?

¦Ñ©Çµª¡G

MyStr ¥[¤W MDIForm ªº¦WºÙ§Y¥i©I¥s¨ì¡A¦p Debug.Print MDIParentForm.Mystr¡C

Origin:·¦ªL­·±¡

¤½¥ÎÅܼÆÀ³¸Ó«Å§i¦b .BAS Module¤¤§a!

¦Ñ©Çµª¡G

¥¼¥²¡ABAS Module ªº¤½¦@Åܼƫŧi¡AÁöµM¦³¨ä¦@³q©Ê¤Î¨Ï¥Î¤è«K¡A¦ý¦pªG¤@­Ó±M®×¥Î¤F³\¦h¼Ò²Õ¡A©Î¬O¦h¤H¶}µoªº¦X¤O±M®×¡A«h©¹©¹¬O¨t²Î¿ù»~ªº¨Ó·½¡A¦]¬°¤£¦Pªº¼Ò²Õ¦pªG«Å§i¤F¦P¦WªºÅܼơA·|³y¦¨°õ¦æ¿ù»~¡A¦Ó¥B³oºØ¿ù»~¦b½sͶ¥¬q¬OµLªk¥Ñ½s;¹µo²{ªº¡A¤]¬O Bug ªº¨Ó·½¡C

¦ý¦b Form ªº¤½¦@Åܼƫŧi¡A«h¦]¦³ Form ¼Ò²Õªº°Ï¹j¡A¦]¦¹¤£·|¦³½Ä¬ðªº±¡ªpµo¥Í¡A³o¦b¦h¤H¶}µoÀô¹Ò¤Î¼Ò²Õ¾ã¦X¤W«O»Ù¤F­Ó§O Form ªº¥¿½T°õ¦æ¤Î©¼¦¹©I¥sªº«K§Q¡C©Ò¥H¡A¦b³Ì¤jªº¥i¯à½d³ò¡A§Ú­ÌÀ³¤Ö¥Î BAS ªº Public Åܼƫŧi¡A¦Ó¥N¥H Form ªº Public «Å§i¡C

¦^¯Á¤Þ


ÅܼƭȮø¥¢¤F


¹ï¿ù³£¬O¬°¤F·R ¼¶¼g©ó¤å³¹

    Private Sub FindName_Click()
    strInput = InputBox(........¬Ù)
    dtaCrtve.Recordset.FindFirst "Name Like '*" & RTrim(strInput) & "*'"

    Private Sub NameOneMore_Click()
    dtaCrtve.Recordset.FindNext "Name Like '*" & RTrim(strInput) & "*'"

¥Ñ©ó¤G­Ó¬O¤£¦Pªºµ{§Ç¡A©Ò¥HÅÜ¼Æ strInput ¦b¥Ñ InputBox ¿é¤J¨M©w«á¡A¨ì¤F NameOneMore ³o­Óµ{§Ç´NÅܬ°ªÅ¦r¦ê¤F¡C§Ú·Q°Ýªº¬O¡A­n¦p¦ó§â strInput ÅܼƤº®e¥Ñ FindName ³o­Óµ{§Çµ¹¶Ç»¼¨ì NameOneMore¡H

¦Ñ©Çµª¡G

  1. .§A¥u­n¦b¤@¯ë°Ï«Å§i
    Dim strInPut As String
    ´N¥i¥H¦b¤£¦Pªº Procedure ¤¤¶Ç»¼ strInPut ªº­È¡C
  2. .§Ú²q§A·|²£¥Í³oºØºÃ°Ý¬O¦]¬°¨S¦³¾i¦¨¨}¦nªº­n¨DÅܼƫŧiªºµ{¦¡¼g§@²ßºD¾É­Pªº¡A½Ð¥H«á¦b¼g VB5 µ{¦¡®É¡A¤@©w­n¦b³Ì¶}ÀY¥[¤W Option Explicit¡A³o·|­n¨D VB ¦b¸I¨ì¥¼«Å§iÅܼƮɳqª¾§A°µÅܼƫŧi¡C
  3. ±µµÛ¸ÑÄÀ³oºØ²{¶Hªº­ì¦]¡G
  4. ³Ì«á¦A­«¾ã²z¤@¦¸¡G

¦^¯Á¤Þ


ÅX°Ê¦Lªí¾÷ªº°ò¥»«ü¥O


  1. ¥Î Printer.PaperSize=value ³]©w¯È±i¤j¤p¡C
  2. ¥Î ScaleLeft,ScaleTop,ScaleWidth,ScaleHeight ³]©w¯È±iªº¥|­Ó¦C¦LÃä¬É¡C
  3. ¥Î Printer.CurrentX=singlevalue , Printer.CurrentY=singlevalue ³]¦L¦rÀY¦ì¸m¡C
  4. Printer.Print "StrringValue" ¿é¥X¦r¦ê¡C
  5. Printer.Paintpicture Image µe¼v¹³¹Ï
  6. Printer.Circle or Printer.Line µe¶ê©Îª½½u
  7. Printer.EndDoc §â¸ê®Æ°e¨ì¦Lªí¾÷¦C¦L
  8. ³]©w¹w³]¦Lªí¾÷
    Dim P As Object
    For Each P In Printers
    If P.Port = "LPT2:" Or P.DeviceName Like "*LaserJet*" Then
    '------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    '-----------------------³oùجO¿ï¾Ü§PÂ_

      Set Printer = P
      Exit For
    End If
    Next P

¦^¯Á¤Þ


¤£¸Ó·¸¦ìªº·¸¦ì


(Xavier21) ªº¤j§@¤¤´£¨ì

       dim i as double
        i=1000*1000

µ²ªG³ºµM¥X²{·¸¦ìªº°T®§,¦Ó¥B§Ú¤À§O¦b§O¤Hªº¹q¸£¤W¤]°µ´ú,¸Õ,µ²ªGÁÙ¬O¤@¼Ë

¦Ñ©Çµª¡G

¦Ñ©Ç´¿¦^µª¬O Bug ¡A¦ý¸gª©¤W°ª¤â«üÂI¡A¤§©Ò¥H·|¦³¦¹ºØ²{¶H¡A¬O¦]¬° VB ¹Bºâªk«h¨ÏµM¡A¦]¬° VB ·|§â¨â¼Æ¹Bºâªºµ²ªG©ñ¨ì»P«á¤@­Ó¹Bºâ¤¸¬Û¦P«¬ºAªºÅܼƤ¤¡A¥Ñ©ó 1000 ÄÝ©ó Integer ½d³ò¡A©Ò¥H 1000000 ¶W¹L Integer ªø«×¡A¦]¦¹²£¥Í·¸¦ì¿ù»~¡C

¦ý§Úı±o³o»ò»¡¬O¤£³qªº¡A¦]¬°¦pªG§Ú­Ì°õ¦æ i=0.111111111111111 * 1000 ©úÅ㪺¹Bºâµ²ªG¶W¹L¤F Integer ½d³ò¡A¦ý«o¨S¦³¿ù»~¡A¹Bºâµ²ªG¬O i=111.111111111111¡C

©Ò¥H©úÅ㪺 VB ­pºâªk«h¤£²Î¤@¦Ó¦³¨Ç¯É¶Ã¡A°µ¬°¤@­Ó¨Ï¥ÎªÌ¡A°£¤F´Á«Ý VB ¯à§ïµ½¦¹ÂI²V¶Ã¥~¡A©Î³\¥u¯à¥Î¬Yª©¤Í´£¨Ñªº¿ìªk¡A i=1000 * CDbl(1000) ±j­¢«á¤@¹Bºâ¤¸Âন Double¨Ó«OÃÒµ{¦¡¤£¥X¿ù¡A©Ò¥H i ³Q«Å§i¬O¤°»ò«¬ºA¡A«á¹Bºâ¤¸´N­nÂন¤°»ò«¬ºA¡A¬O«O»Ùµ{¦¡¤£¥X¿ùªº¿ìªk¡C

¦^¯Á¤Þ


µLªk¦b With °Ï¶ô¤¤°õ¦æªº°Ê§@


¦Ñ©Ç¡G

  1. VB5 µo®i¥X With °Ï¶ôµ{¦¡¼¶¼gªk¡A¬°µ{¦¡½XªºÂ²¬Ù´£¨Ñ¤F³\¦hÀ°§U¡A¦Ó¾Ú VB Help ªº»¡©ú¡A¦¹ºØ¦]Âê©w³æ¤@ª«¥ó°õ¦æ°Ê§@¡A¤£¶·¨C¦æ±Ô­z³£¥h¤ñ¹ï¥Øªºª«¥ó¡A¦³§U©óµ{¦¡¥[§Ö°õ¦æ¡Aªº½T¬O¤@¶µ¨}¦nªº³]­p¡C
  2. ¦ý VB5 ¦ü¥G¤S¥Ç¤F¿òº|¦Ó¤£²Î¤@ªº¤ò¯f¡A¨º´N¬O¹³ Form , PictuireBox ªº¿é¥X°Ê§@¡A¦b With °Ï¶ôùصLªk°õ¦æ¡A¦p¡G
    With Picture1
    .Print "ABCD"
    .Line ..............
    .Circle ............
    End With
    VB ¤@·§¦^À³§ä¤£¨ì¤èªk©Î¸ê®Æ¦¨­û¡A¥²¶·
    With Picture1
    Picture1.Print "ABCD"
    Picture1.Line ..............
    Picture1.Circle ............
    End With
    VB ¤~¯à°Ê§@¥¿½T
  3. ­Y§A»¡¤j·§¿é¥Xªº¤èªk³£·|¾É­P¦p¦¹µ²ªG¡A«o¤]¤£µM¡A¦p¡G
    With Picture1
    .PaintPicture Image1.Picture ,0,0
    End With
    µ²ªG«o¬O¥¿½T¡C
  4. ÁöµM VB Help ¦b³Ì«á¤@¤p¦æ¦³»¡©ú Line µ¥¤èªk¤£¾A¥Î With °Ï¶ô¡A¦ý§¹¥þ¨S¸ÑÄÀ­ì¦]¬°¦ó¡A©Ò¥Hµy¤£ª`·N¡A´N³y¦¨µ{¦¡¿ù»~¡A³oºØ¨S¹D²zªº¨Ò¥~±¡ªp¡A®{¼W¨Ï¥ÎªÌ§xÂZ¦Ó¤w¡C

¦^¯Á¤Þ


¥­¶¶ªºÁä½L²¾°Ê


ºÃ´bªº¤H

±ý¥HKeyboard±±¨î¹Ï§Î²¾°Ê,¦p¦ó¤~¯à¨Ï¹Ï§Î²¾°Êªº§ó¬y§Q¡A¦Ó¤£·|¦³¥ý²¾°Ê¤@®æ  ==>  Delay  ==> ¦A³sÄò¤£°±ªº²¾°Êªº²{¶H©O?

¦Ñ©Çµª¡G

  1. ¥HÁä½L²¾°Ê¹Ï§Î¡A´N­n©ú¤F KeyBoard ¦b VB ùؤ޵o¨Æ¥óªº¶¶§Ç¡A·í§Ú­Ì«ö¤U¤@Áä­º¥ý¬O KeyDown ¤@¦¸¡A±µµÛ¬O³sÄòªº KeyPress¡Aª½¨ì©ñ¶}«öÁä¡AKeyPress µ²§ô,KeyUp ²£¥Í¤@¦¸¡A´N¦X¦¨¤F¤@­Ó«öÁä´`Àô¡C
  2. Áä½L«ö¤U¦h¤[·|¤Þµo KeyDown ¨Æ¥ó¡A¤Î KeyPress ¦h¤[·|­«ÂФ@¦¸¡A¸ò WinDows Áä½L³]©w¦³Ãö¡A¸òµwÅé³t²v§ó¦³Ãö¡A©Ò¥H¨C¥x¹q¸£ªºªí²{³£¤£¤@¼Ë¡A¦]¦¹¥ÎKeyBoard ¥hÅX°Ê¹Ï§Î²¾°Ê¥²µM·|¦³¤£¦P¹q¸£³]³Æ¤W·|¦³¤£¦Pªºªí²{¡A¦ÓµLªk°µ¨ìí©wªºªí²{¡C
  3. ¹ï©ó¹CÀ¸µ{¦¡¨Ó»¡¡A³o¬O­Ó¥²¶·¬ð¯}ªºÃøÃö¡A¤U­±¬O¤@ºØ¸Ñ¨Mªº¿ìªk¡G

¦^¯Á¤Þ


³sµoªº·Æ¹««öÁä


¦Ñ©Ç¡G

·Æ¹««öÁ䪺«öÁä²Õ¦X¡A»P«e­zÁä½L«öÁä²Õ¦X¦³«Ü¤jªº¤£¦P¡C

Option Explicit

Dim Working As Boolean

Private Sub ContinueClick()
Dim I As Long

Do While Working
I = I + 1
Label1.Caption = I
DoEvents
Loop
End Sub

Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Caption = ""
Working = True
ContinueClick
End Sub

Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
Working = False
End Sub

¦^¯Á¤Þ


¤@­Ó²³æªº¶i«×ªí


ellen ¼¶¼g©ó¤å³¹

·í§Ú«ö¤U¤@­Ó«ö¶s,³o­Ó«ö¶s·|¥h°õ¦æforªº°j°é,¦Ó¦¹°j°é»Ý°õ¦æ¤@¬q®É¶¡...§Ú·Q­n¦bµ¥«Ýªº®É¶¡¤¤,¼g¤@­Ó¥X²{¦Ê¤À¤ñªºªF¦è.....·íµ{¦¡¶]§¹,¦¹¦Ê¤À¤ñ¤]µ²§ô...¤£ª¾vb¸Ó¦p¦ó¼g......

¦Ñ©Çµª¡G

Private Sub Command1_Click()
Dim I As Long
For I = 1 To 100000
'§Aªºµ{¦¡°Ê§@.........................
Label1.Caption = Format(I / 100000, "0%")
DoEvents
Next
End Sub

¦^¯Á¤Þ


°O¿ý¹q¸£¶}¾÷®É¶¡


¥d¥¬¨ä¿Õ) ªº¤å³¹¤¤´£¨ì

¦p¦ó¼g¤@­Óµ{¦¡....¦b¶}¾÷®É©Î¶iwin95¥H«á.....¿Ã¹õÅã¥Ü¥X¤W¦¸¶}¾÷®É¶¡.....

©_²§ªG ¼¶¼g©ó¤å³¹

§A¥i¥H¼g¤@­Óµ{¦¡,¥Lªº¥\¯à¬O:

  1. Ū¨úDatabase¸Ì³Ì«á¤@µ§¬ö¿ý,¨Ã¥ÎMessageBoxÅã¥Ü¥X¨Ó
  2. ¬ö¿ý¸Óµ{¦¡°õ¦æ®Éªº®É¶¡,¦s¦¨¦Û­qªºDatabase®æ¦¡
  3. µM«á§âµ{¦¡©ñ¨ì"±Ò°Ê"¸Ì´N¥i¥H¤F.

sonic ¼¶¼g©ó¤å³¹

½Ð°Ý¥i§_¥Î¨ä¥L¤èªk©O¡H¦]¬°¥ÎDatabase¤S·|¥Î¨ìDAOªºDLL°Ú¡I

¦Ñ©Çµª¡G

Option Explicit
Private Sub Command1_Click()
Dim TimeCalc As Date
    TimeCalc = Timer
    Label1.Caption = "§Æ±æ¥»¹q¸£Åý±z¨Ï¥Î´r§Ö"

    Do While Timer - TimeCalc < 1
        DoEvents
    Loop

    Unload Me
End Sub
Private Sub Form_Load()
Dim Today As Date
Dim DayString As String
Dim PathString As String
Dim DateRec As Integer
    Today = Now

    PathString = App.Path
    If Right(PathString, 1) <> "\" Then
        PathString = PathString + "\"
    End If
    If Dir(PathString + "StartPc.log") <> "" Then
        DateRec = FreeFile
        Open PathString + "StartPc.log" For Input As #DateRec
        Line Input #DateRec, DayString
        Close #DateRec

        Label1.Caption = "§A¤W¦¸¶}¾÷¬O[" & DayString & "]"
    Else
        Label1.Caption = "§A²Ä¤@¦¸¨Ï¥Î¥»¹q¸£"
    End If

    DateRec = FreeFile
    Open PathString + "StartPc.log" For Output As #DateRec

    DayString = Today
    Print #DateRec, DayString

    Close #DateRec
End Sub

¦^¯Á¤Þ


¦^­º­¶

1