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

¦^­º­¶


¤ÀÃþ

¼ÐÃD

¤j·N

§@ªÌ

¤é´Á

¦r¦ê³B²z Àɮפ¤¦r¦ê·j´M InStr ¨ç¼Æªº¨Ï¥Î ¦Ñ©Ç 1998/10/25
¦r¦ê³B²z ÀɮץΦr²Î­p ¡@ ¦Ñ©Ç 1998/10/27
¦r¦ê³B²z ¦r¦ê¹ï»ô¿é¥X ¦P¦r¼Æªº¦r¦ê¨Ã¤£µ¥ªø ¦Ñ©Ç 1998/11/8
ÅܼƳB²z For Each ±Ô­z»Pª«¥ó°Ñ·Ó ¡@ ¦Ñ©Ç 1998/10/27
ÅܼƳB²z Collection À³¥ÎÁ|¨Ò ¡@ ¦Ñ©Ç 1998/11/28
ÅܼƳB²z ¤@ª«±±¦h¶µ ª«¥ó°Ñ·Óªº¾Þ§@¤è¦¡ ¦Ñ©Ç 1998/12/2
¤é´Á®É¶¡ ¤½¤åµ²®×¤é­pºâ½d¨Ò ¡@ ¦Ñ©Ç 1998/11/17
¤é´Á®É¶¡ VB ¤p¾xÄÁ½d¨Ò ¡@ ¦Ñ©Ç 1998/11/18
¤é´Á®É¶¡ ®É¶¡¼È°± ¡@ ¦Ñ©Ç 1998/11/28
¹Ï§Î³B²z ½ò¦a¹pµe­±¼ÒÀÀ½d¨Ò Line ¤èªk¤Î PictureBox °Ï¶ô¤À³Î ¦Ñ©Ç 1998/10/30
¹Ï§Î³B²z ¹Ï¤ùªº 90 «×½Âà ¡@ ¦Ñ©Ç 1998/11/5
¹Ï§Î³B²z ¹Ï¤ù±²°Ê²°½d¨Ò ¡@ ¦Ñ©Ç 1998/11/26
ª«¥ó³B²z «ç¼ËÂI¨ú Disable ªºª«¥ó ¥Î Form ±µ¦¬·Æ¹«¨Æ¥ó ¦Ñ©Ç 1998/11/19
¥~³¡µ{¦¡ Åý³à¥¢¾nÂIµ{¦¡«ì´_¾nÂI ¶È­­©ó Shell ±Ò°ÊªÌ ¦Ñ©Ç 1998/10/28
µøµ¡¬É­± Âù½u©T©wµøµ¡ªº¤Á´« ¡@ fumi 1998/9/23
µøµ¡¬É­± Åý ChildForm ¶ñº¡ MDIForm ±ø¥ó¡GChildForm ¤£­n³Ì¤j¤Æ ¦Ñ©Ç 1998/11/10
µøµ¡¬É­± Ãö³¬©Ò¦³µ{¦¡¸ü¤Jªºªí³æ ¤£¯d¤U­t¾áªºµ²§ôµ{¦¡ ¦Ñ©Ç 1998/11/13
¦â±m³]©w ¥Î±²¶b³]©wÃC¦â­È ¡@ ¦Ñ©Ç 1998/11/17
ÀÉ®× I/O ³Ì§Öªº¶}ÀɼҦ¡ Open Binary ¦Ñ©Ç 1998/11/17
ÀÉ®× I/O Àˬd¥Ø¿ý¤¤¯S©wÀɮ׬O§_¦s¦b Dir ¨ç¼Æªº¨Ï¥Î ¦Ñ©Ç 1998/11/26

¡@


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

¦^¯Á¤Þ


Àɮפ¤¦r¦ê·j´M


Eric HSU ¼¶¼g©ó¤å³¹

¦b VB ¸Ì­n«ç»ò¨ú±o¤@­Ó¤å¦rÀɪº¦æ¼Æ¡H¤S¦p¦ó¦b¤@­ÓÀɮפ¤·j´M¯S©w¦r¦ê¡H

¦Ñ©Çµª¡G

'´ú¸Õ¥»½d¨Ò½Ð¦bªí³æ¤W¥¬¸m Label1,2¡BText1,2¡BCommand1
Option Explicit

Private Sub Command1_Click()
Dim FileHandle As Integer
Dim I As Long, SearchPos As Long
Dim LineString As String
Dim LongString As String

FileHandle = FreeFile
Open Text1.Text For Input As #FileHandle

Do While Not EOF(FileHandle)
Line Input #FileHandle, LineString
I = I + 1
LongString = LongString + LineString
Loop

MsgBox "ÀÉ®×Á`¦æ¼Æ¡G" & Str(I)

SearchPos = InStr(1, LongString, Text2.Text)

If SearchPos <> 0 Then
MsgBox "[" & Text2.Text & "]" & "¦b " & Str(SearchPos) & "¦ì¸m"
Else
MsgBox "§ä¤£¨ì[" & Text2.Text & "]"
End If

End Sub

Private Sub Form_Load()
Label1.Caption = "½Ð¿é¤JÀɮצWºÙ"
Label2.Caption = "½Ð¿é¤J·j´M¦r¦ê"

Text1.Text = App.Path
Text2.Text = ""
End Sub

¦^¯Á¤Þ


For Each ±Ô­z»Pª«¥ó°Ñ·Ó


Yih-Jaj Lin ¼¶¼g©ó¤å³¹

½Ð°Ý For Each element In Group ... Next ³o­Ó±Ô­zÀ³¸Ó¦p¦ó¨ÓÀ³¥Î?§Ú¬Ý¤F½u¤W¤â¥U,¦ý¬O¨S¦³¹ê»Ú¨Ò¤l,©Ò¥HÁÙ¬O¤£¬ÆÁA¸Ñ¡H

¦Ñ©Çµª¡G

¥ýÁ|½d¨Ò¡G

  1. µ{¦¡¥Ø¼Ð¡G
    §ä¥X Form ¤W©Ò¦³ CommandButton Control¡A¨Ã§â¥¦­Ìªº Caption §ï¦¨ "©R¥O"+§Ç¦C¼Æ¦r¡C
  2. µ{¦¡½d¨Ò¡G
    Dim SetControl As Control
    Dim I As Integer

        I = 1

        For Each SetControl In Me.Controls
            If TypeName(SetControl) = "CommandButton" Then
                SetControl.Caption = "©R¥O" & I
                I = I + 1
            End If
        Next

¦A»¡ For Each...±Ô­zªº­n»â¡G

  1. Element ¥²¶·¬O¦b¶°¦Xª«¥ó¤¤ªº¤@­Óª«¥ó¡C
  2. ¦]¬° Element ¬Oª«¥ó¡A©Ò¥H¥¦ªº«Å§i¥²¶·¬O [ª«¥ó³q¥Î¦WºÙ]¡B[Object] ©Î [Variant] ¡A¨ä¤¤¥Hª«¥ó³q¥Î¦WºÙ®Ä²v³Ì¦n¡AObject ¦¸¤§¡AVariant ³Ì®t¡A¦ý¤TªÌ¬Ò¯à¹F¦¨¥Øªº¡C
  3. ¦]¬° Element ¬O¦b¶°¦Xª«¥ó¤¤ªº¤@­Óª«¥ó¡A©Ò¥H§A¥²¶·ª¾¹D¥¦¶°¦X¦WºÙ¬O¤°»ò¡A¦p Form ¤W©Ò¦³ªº±±¨î¶µ¶°¦X¦WºÙ¬° Me.Controls or FormName.Controls¡C
  4. ·í«Å§iª«¥óÅܼÆ(¦p SetControl)¹ï·Ó¨ì¶°¦Xª«¥ó¤¤¬Y¤@ª«¥ó®É¡A§Y©M¸Óª«¥ó²£¥Í°Ñ·ÓÃö«Y(¦p CommandButton)¡A§A¥i¨Ï¥Î¸Óª«¥óªº©Ò¦³ÄݩʡB¤èªk¡A¹ï«Å§iª«¥óÅܼÆ(¦pSetControl)ªº©Ò¦³³]©w¡A³£±N¤Ï¬M¦b°Ñ·Óª«¥ó(CommandButton)¤W¡C©Ò¥H For Each ¥u¬O±Nª«¥óÅܼƳv¤@°Ñ·Ó¨ì¶°¦Xª«¥ó¤¤¡A¯u¥¿­«­nªº¬O§A­n¹ï¶°¦Xª«¥ó°µ¦óºØ³]©w¡C
  5. ª«¥óÅܼƹﶰ¦Xª«¥óªº°Ñ·ÓÃö«Y¨Ã¤£ÀH For Each °j°éµ²§ô¦Óµ²§ô¡A¦pªG°j°é¦ÛµMµ²§ô¡A¨ºª«¥óÅܼƬO°Ñ·Ó¶°¦X¤¤³Ì«á¤@­Óª«¥ó¡C¦pªG¨Ì±ø¥ó±Ä¥Î Exit For ¤è¦¡±j­¢µ²§ô¡A¨º»òª«¥óÅܼƬO°Ñ·Ó Exit ±Ô­z«eªº¨º­Óª«¥ó¡A³o¦³¥H¤U¨â­Ó·N¸q¡G
    • ´N°O¾ÐÅé¨Ï¥Î¦Ó¨¥¡A°£«D¨Ï¥Î Set ª«¥óÅܼÆ=Nothing ¡A§_«hª«¥óÅܼƷ|¤@ª½¦û¦³­ì°O¾Ð°Ï¶ô¡AµM«á¨Ì·ÓÅܼƥͦs­ì«h³Qµ²§ô¡A¦b°Ï°ìùثŧiªº¦b°Ï°ìµ²§ô®Éµ²§ô¡A¤½¥ÎÅܼƫh¦bµ{¦¡µ²§ô®Éµ²§ô¡C
    • ´N°Ñ·ÓÃö«YªºÄ~Äò¨Ï¥Î¦Ó¨¥¡A¦b°Ï°ìµ{§Çùثŧiªºª«¥óÅܼƦb For Each °j°éµ²§ô«á¥i¥HÄ~Äò¨Ï¥Î¨ä°Ñ·ÓÃö«Y¡Aª½¨ì°Ï°ìµ{§Çµ²§ô¬°¤î¡C¤½¥Îª«¥óÅܼơA«h¦b¥þ³¡¼Ò²Õ³£¥i¥HÄ~Äò¨Ï¥Î¨ä°Ñ·ÓÃö«Y¡Aª½¨ì§A Set Nothing or µ{¦¡µ²§ô¡C

¡@

¦^¯Á¤Þ


ÀɮץΦr²Î­p


­`½¶ªÞ ¼¶¼g©ó¤å³¹

½Ð°Ý¸Ó¦p¦ó¼g¤@¤ä¯à±N¤@­^¤å¦r¦êªº©Ò¦³­^¤å¦r¥À¡B¼ÐÂI²Å¸¹¡BªÅ®æ¡B¼Æ¦r©Ò¥X²{ªº¦¸¼Æµ¹²Î­p¥X¨Ó«¨????????

¦Ñ©Çµª¡G

Option Explicit

'´ú¸Õ¥»µ{¦¡½Ð©ó¼Ð³æ¤W¥¬¸m Command1,2,3¡BLabel1¡BList1 ¤Î
'CommonDialog1
'Àx¦s©Ò¦³¦r½X¤§°}¦C
Dim varCalc(32766) As Long

'¦U¦r¤¸¨Ï¥Î¦¸¼Æ²Î­p
Private Sub Command1_Click()
'ÀÉ®×¥N¸¹
Dim FileHandle As Integer
'¤¤¤å¦r½X­t¸¹Âà´«
Dim CharNo As Integer
Dim I As Long
'¤G¶i¨úÀɤ§ Buffer
Dim Buff() As Byte
'³v¦r¨ú¥X¤§ªøµuÅܼÆ
Dim LongString As String, ShortString As String * 1
'Àɮ׸ô®|¤Î¦WºÙ
Dim FileString As String

    '²M°£«e¦¸³]©w
    CommonDialog1.filename = ""
    '±Ò¥Î¶}Àɹï¸Ü²°
    CommonDialog1.ShowOpen
    '¨ú±oÀɮ׸ô®|¤Î¦WºÙ
    FileString = CommonDialog1.filename

    If FileString = "" Then
        MsgBox "¥¼¿ï¾Ü¨Ï¥ÎÀɮסAµLªk²Î­p¡C", vbOKOnly, "Àɮ׿ù»~"
        Exit Sub
    End If

    Me.MousePointer = 11

    '²M°£¤W¤@¦¸ªº¶µ¥Ø
    List1.Clear

    '¥Î Byte °}¦C¼Ò¦¡¶}Àɳt«×¤ñ¸û§Ö
    FileHandle = FreeFile
    Open FileString For Binary As #FileHandle
    ReDim Buff(LOF(FileHandle) - 1)
    Get #FileHandle, , Buff
    Close #FileHandle

    '§â byte °}¦C¦r½XÂন Unicode¡A©ñ¤J LongString ¤¤
    '¥H«K³v¦r¨ú¥X
    LongString = StrConv(Buff, vbUnicode)
    '²M°£ Buffer ¦û¥Îªº°O¾ÐÅéªÅ¶¡
    Erase Buff

    For I = 1 To Len(LongString)
        '´`§Ç¨ú¥X¤@¦r
        ShortString = Mid(LongString, I, 1)
        '¨ú±o¸Ó¦r½X¤§µ´¹ï­È
        CharNo = Abs(Asc(ShortString))
        '±N»P¨ä¹ïÀ³¤§°}¦C«ü¯Á¤Þ­p¼Æ¥[ 1
        varCalc(CharNo) = varCalc(CharNo) + 1
    Next

    '©ñ¨ì ListBox ùØÅã¥Ü²Î­pµ²ªG
    For I = 0 To UBound(varCalc)
        '­p¼Æ¤£¬° 0 ªº¤~Åã¥Ü
        If varCalc(I) > 0 Then
            CharNo = I
            '¤¤¤å¦r½X¬O­t¼Æªº¡A©Ò¥H­n§â°}¦C¯Á¤Þ¥[­t¸¹
            If CharNo > 255 Then CharNo = -CharNo
            List1.AddItem "[" & Chr(CharNo) & "]" & varCalc(I)
        End If
        DoEvents
    Next

    '¦³¶}Àɤ~¯à¦sÀÉ
    Command2.Enabled = True

    Me.MousePointer = 0
End Sub

'±N²Î­p¼Æ­È¦s¦¨¦s¤å¦rÀÉ
Private Sub Command2_Click()
Dim FileHandle As Integer, CharNo As Integer
Dim FileString As String
Dim I As Long

    CommonDialog1.filename = ""
    CommonDialog1.ShowSave
    FileString = CommonDialog1.filename

    If FileString = "" Then
        MsgBox "¥¼¿ï¾Ü¨Ï¥ÎÀɮסAµLªk¦sÀÉ¡C", vbOKOnly, "Àɮ׿ù»~"
        Exit Sub
    End If

    Me.MousePointer = 11

    '¶}±Ò¿é¥XÀÉ
    FileHandle = FreeFile
    Open FileString For Output As #FileHandle

    For I = 0 To UBound(varCalc)
        '­p¼Æ¤£¬° 0 ªº¤~¦s¤J
        If varCalc(I) > 0 Then
            CharNo = I
            If CharNo > 255 Then CharNo = -CharNo
            Write #FileHandle, Chr(CharNo), varCalc(I)
        End If
    Next

    Close #FileHandle

    Me.MousePointer = 0
End Sub

Private Sub Command3_Click()
    Unload Me
End Sub

Private Sub Form_Load()
    Me.Caption = "ÀɮץΦr²Î­p"
    Label1.Caption = "²Î­pÆ[¹îµ¡"
    Command1.Caption = "¶}±ÒÀÉ®×"
    Command2.Caption = "¦s¦¨ÀÉ®×"
    Command2.Enabled = False
    Command3.Caption = "µ²§ô"

    '°ÆÀɦW¹w³]¬O TXT
    CommonDialog1.DefaultExt = "txt"
    CommonDialog1.Filter = "¤å¦rÀÉ (*.txt)|*.txt|©Ò¦³ÀÉ®× (*.*)|*.*"
    CommonDialog1.InitDir = App.Path
End Sub

¦^¯Á¤Þ


Åý³à¥¢¾nÂIµ{¦¡«ì´_¾nÂI


¬q ÅA ¼¶¼g©ó¤å³¹

½Ð°Ý¤@¤U¦bVB¤¤§Ú§Q¥Îshell°õ¦æ¥~³¡µ{¦¡,«ü©w¥~³¡µ{¦¡¤£¾Ö¦³¾nÂI, ¥B³Ì¤p¤Æ (´N¬O°Ñ¼Æµ¹ 6)­n«ç»ò°µ¤~¯àÅý³o­Óµ{¦¡«ì´_¦¨¥þ¿Ã¹õ¤j¤p¡H

¦Ñ©Çµª¡G

Dim AppNum As Variant

Private Sub Command1_Click()
    AppNum = Shell("c:\windows\notepad.exe", vbMinimizedNoFocus)
End Sub

Private Sub Command2_Click()
    AppActivate AppNum
    SendKeys "{ENTER}"
End Sub

¦^¯Á¤Þ


½ò¦a¹pµe­±¼ÒÀÀ½d¨Ò


±H¥óªÌ: terry

½Ð°Ý¦p¦ó¼g¹³½ò¦a¹p¤@¹³¥i³]©w¼e°ª«×,«ö¤U·Æ¹«¤è¶ô´N·|¤U¨I.

¦Ñ©Çµª¡G

  1. §Ú­Ì¥i¥H¥Î¦b¤è¶ô¹ÏÃä½uµe©ú½u¤Î·t½uªº¤è¦¡§@¥X¥Y°_¤Î¥W³´ªº®ÄªG¡C
  2. ¤è¶ô¦æ¦C¬GµM¥i¥H¥Î N*N ­Óø¹Ïª«¥ó¨Óºc¦¨¡A¦ý¤Ó¯Ó¶O°O¾ÐÅé¤F¡C§Ú­Ì¥i¥H¥Î N*N ­Ó°}¦CÅܼƹïÀ³¨ì¤@­Ó PictureBox ªº¦U­Ó¤è®æ°Ï°ì¡A¦bÅܼƤ¤°O¿ý¤è¶ô¹Ïªº¥Y°_¤Î¥W³´¡A¦A¦b PictureBox ¤W¤@­Ó°Ï¶ô¤@­Ó°Ï¶ôªºµe¥X¤è¶ô¹Ï¨Ó¡C
  3. ½d¨Ò¦p¤U¡G
    '¥»½d¨Ò¥Î¤@±i¥Y°_¹Ï¤Î¥­­±¹Ï(¥Ñµ{¦¡¦Û¦æÃ¸»s¡A¤£¶·¸ü¤J¹ÏÀÉ¡C)
    '¨Ó¼ÒÀÀ½ò¦a¹p¹CÀ¸¤§¾Þ§@µe­±
    '¾Þ§@¥»½d¨Ò½Ð¦b Form ¤W¥¬¸m Picture1,Command1
    Option Explicit
    '¤@®æªº¼e«×¡A³æ¦ì Pixel
    Const GRIDLENGTH As Integer = 16
    'Ãä½u¼e«×¡A³æ¦ì Pixel
    Const BODERWIDTH As Single = 1.5
    'Âà´««áÃä½u¼e«×
    Dim LineWidth As Single
    'Âà´««á®æ¤l¼e«×
    Dim GW As Single
    'Âà´««á®æ¤l°ª«×
    Dim GH As Single
    '¾î¶b®æ¤l¼Æ
    Dim GridHNum As Integer
    'Áa¶b®æ¤l¼Æ
    Dim GridVNum As Integer
    '¥­­±¤Î¥Y°_¹Ï§Î°}¦C
    Dim GridPic(1) As Picture
    'µù°O¨C¤@®æ¤l¥Y°_¤Î¥W³´ª¬ºAªº°}¦C
    Dim GridNote() As Byte
    '­«ª±³]©w
    Private Sub Command1_Click()
    Dim I As Long

        '±N©Ò¦³¹Ï§Î³£Á٭즨¥Y°_
        For I = 0 To UBound(GridNote)
            GridNote(I) = 0
        Next

        'µeªO­«Ã¸
        Picture1_Paint
    End Sub
    Private Sub Form_Load()
        With Picture1
            'µeºâ 16 ÂI Pixel ®æ¤l¬Û¹ï°ª«×¤Î¼e«×
            GW = ScaleX(GRIDLENGTH, vbPixels, .ScaleMode)
            GH = ScaleY(GRIDLENGTH, vbPixels, .ScaleMode)
            '´«ºâ®æ¤lÃä½u¼e«×
            LineWidth = ScaleX(1, vbPixels, .ScaleMode) * BODERWIDTH
            '¥ýºû«ù Picture1 ¤@®æ¤j¤p¡A¥H§Q°ò¥»¹Ï§Îø»s¡C
            .Width = GW + .Width - .ScaleWidth
            .Height = GH + .Height - .ScaleHeight
        End With
        '°õ¦æµe¥­­±¹Ï¤Î¥Y°_¹Ï¤§¦Û­q¨ç¼Æ
        GetGridPic LineWidth

        '³]©w¾î¶bÁa¶b®æ¼Æ³£¬O 8
        GridHNum = 8
        GridVNum = 8
        With Picture1
            '³]©w Picture1 ¥i®e¯Ç 8*8=64 ­Ó®æ¤lªº¤j¤p¡C
            .Width = GW * GridHNum + .Width - .ScaleWidth
            .Height = GH * GridVNum + .Height - .ScaleHeight
            '²¾°Ê©R¥O¯Ã¦ì¸m
            Command1.Move .Left + .Width + GW, .Top
            '½Õ¾ãªí³æ¤j¤p
            Me.Width = .Left + .Width + Command1.Width + _
                    GW * 2 + Me.Width - Me.ScaleWidth
            Me.Height = .Top + .Height + GH + Me.Height - _
                    Me.ScaleHeight
        End With

        '³]©w GridNote Á`¼Æ¬° 64 ­Ó
        ReDim GridNote(GridHNum * GridVNum - 1)

        Command1.Caption = "­«ª±"
        Me.Caption = "½ò¦a¹pµe­±¼ÒÀÀ½d¨Ò"
    End Sub
    'µe¥­­±¹Ï¤Î¥Y°_¹Ï¤§¦Û­q¨ç¼Æ
    Private Sub GetGridPic(ByVal Width As Single)
        '¥ý§â¥­­±¹Ï³]µ¹ GridPic(1)
        Set GridPic(1) = Picture1.Image
        '¥´¶} AutoRedraw ¥\¯à¤~¯à°O¿ýø¹Ï°Ê§@
        Picture1.AutoRedraw = True
        '¤ÁÂ_ GridPic(1) »P Picture1.Image ªº°Ñ·Ó
        Picture1.Cls
        '¤W¬É¥ÕÃä
        Picture1.Line (0, 0)-(GW, Width), QBColor(15), BF
        '¥k¬É¶ÂÃä
        Picture1.Line (GW - Width, 0)-(GW, GH), QBColor(0), BF
        '¤U¬É¶ÂÃä
        Picture1.Line (GW, GH - Width)-(0, GH), QBColor(0), BF
        '¥ª¬É¥ÕÃä
        Picture1.Line (Width, GH)-(0, 0), QBColor(15), BF
        '§â¥Y°_¹Ï³]µ¹ GridPic(0)
        Set GridPic(0) = Picture1.Image
        '²M±¼ Picture1
        Picture1.Cls
        'Ãö±¼ AutoRedraw ¥\¯à¥H¸`¬Ù¨t²Î¸ê·½
        Picture1.AutoRedraw = False
    End Sub
    '¦b«ü©w½s¸¹ªº®æ¤l¤¤Ã¸¹Ï
    Private Sub PaintGridPic(ByVal ArrayNo As Byte)
    '¾î¶b²Ä´X®æ
    Dim HNo As Integer
    'Áa¶b²Ä´X®æ
    Dim VNo As Integer

        VNo = ArrayNo \ GridHNum
        HNo = ArrayNo Mod GridHNum
        With Picture1
            '¨Ì GridNote(ArrayNo) ªºÀx¦s­È¨M©wÅã¥Ü¹Ï§Î
            If GridNote(ArrayNo) = 0 Then
                'Åã¥Ü¥Y°_¹Ï
                .PaintPicture GridPic(0), GW * HNo, GH * VNo
            Else
                'Åã¥Ü¥­­±¹Ï
                .PaintPicture GridPic(1), GW * HNo, GH * VNo
            End If
        End With
    End Sub
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As
    Single, Y As Single)
    Dim CalcNo As Long
    Dim WNo As Integer, HNo As Integer

        '¨Ì·Æ¹«¦ì¸m´«ºâ¥X®æ¤l½s¸¹¡A
        '¦A¨Ì½s¸¹µe¥X¹Ï§Î
        If Button = 1 Then
            WNo = X \ GW
            HNo = Y \ GH
            CalcNo = HNo * GridHNum + WNo
            '³]©w°}¦C¬Û¹ï¤¸¯Àµù°O¬°¥­­±¹Ï
            GridNote(CalcNo) = 1
            '±N½s¸¹°e¨ì PaintGridPic ¦Û­q¨ç¼Æ
            PaintGridPic CalcNo
        End If
    End Sub
    Private Sub Picture1_Paint()
    Dim I As Long
        '³v¤@ø¥X¦U®æ¤l¹Ï§Î
        For I = 0 To UBound(GridNote)
            PaintGridPic I
        Next
    End Sub

¦^¯Á¤Þ


Âù½u©T©wµøµ¡ªº¤Á´«


£~£²¯í°Õ... ¼¶¼g©ó¤å³¹

·í¤@­Óform³]©w¬°Âù½u©T©w®É,³o¤@­Óµ{¦¡¦b°õ¦æªº®É­Ô,>´NµLªk¥Îalt+tab¥h¤Á´«,¦n¹³¬OÅܦ¨­I´º°õ¦æªºµ{¦¡¤F...¦³¨S¦³¿ìªk¥i¥H¥[¥H¸Ñ¨M©O??

fumi 榭G

ShowInTaskbar ³]¬° True....

¦^¯Á¤Þ


¹Ï¤ùªº 90 «×½Âà


YQ ¼¶¼g©ó¤å³¹

½Ð°Ý¤@¤U§r­n«ç¼Ë¦bVB¤¤±N¹Ï¤ùÅý¥L±ÛÂà§r

¦Ñ©Çµª¡G

'°õ¦æ¥»½d¨Ò½Ð©óªí³æ¤W¥¬¸m Command1,2,3,4¡BPicture1,2
'¥»½d¨Ò¥u¤ä´© 90 «×±ÛÂà¡A¹w¥ô·N¨¤«×±ÛÂà¹Ï§Î¡A¥²¶·¨Ï¥Î¤T¨¤¨ç¼Æ¡A
'½d¨Ò½Ð°Ñ¦Ò CWW http://sunh.hosp.ncku.edu.tw/~cww/ VB¤ß±oµ§°O
Option Explicit
'API SetPixel ¦b VB ùج۹ïÀ³¥\¯à¬° PSet ¡AGetPixel ¬° Point ¡A
'¦ý¬°¨D§ó§Ö³tµeÂI¡A¬G±Ä¥Î API ¡C
Private Declare Function SetPixel Lib "gdi32" (ByVal hdc As Long, _
        ByVal X As Long, ByVal Y As Long, ByVal crColor As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, _
        ByVal X As Long, ByVal Y As Long) As Long
'¹Ï°Ï°ª«×¤Î¼e«×
Dim PicWidth As Integer, PicHeight As Integer
'Ãä¬É¼e«×
Dim TransX As Single, TransY As Single
'¬O§_¶i¦æ±ÛÂ୫ø
Dim ReDraw As Boolean
'¤ô¥­Â½Âà¶s
Private Sub Command1_Click()
    With Picture1
        '³]¬° AutoRedraw ³]¬° True ¤~¯à¨ú±o Picture1.Image
        .AutoRedraw = True
        '³]©w¶i¦æ±ÛÂ୫ø¡A§í¨î Picture1_Paint ­«Ã¸¥\¯à
        ReDraw = True
        '¤ô¥­Â½Â઺­ì²z¦b§âø¹Ï°_©lÂI³]¬°¥kºÝ¡A¦Ó¼e«×¬°­t¼Æ¡C
        .PaintPicture Picture2.Image, PicWidth - 1, 0, -PicWidth, PicHeight,
_
                0, 0, PicWidth, PicHeight
        .AutoRedraw = False
        Picture2.Picture = .Image
        '³]©w±ÛÂ୫øµ²§ô¡A¶}©ñ Picture1_Paint ­«Ã¸¥\¯à
        ReDraw = False
    End With
End Sub
'««ª½Â½Âà¶s
Private Sub Command2_Click()
    With Picture1
        .AutoRedraw = True
        ReDraw = True
        '««ª½Â½Â઺­ì²z¦b§âø¹Ï°_©lÂI³]¬°©³ºÝ¡A¦Ó°ª«×¬°­t¼Æ¡C
        .PaintPicture Picture2.Image, 0, PicHeight - 1,
PicWidth, -PicHeight, _
                0, 0, PicWidth, PicHeight
        .AutoRedraw = False
        Picture2.Picture = .Image
        ReDraw = False
    End With
End Sub
'¶¶®É°w 90 ¶s
Private Sub Command3_Click()
Dim I As Integer, J As Integer
    With Picture1
        'Picture1 °ª«×¼e«×¤¬´«
        .Width = ScaleX(PicHeight, vbPixels, Me.ScaleMode) + TransX
        .Height = ScaleY(PicWidth, vbPixels, Me.ScaleMode) + TransY
        ReDraw = True
        .Visible = False
        .AutoRedraw = True

        '­ì²z¡G§â Picture2 Áa½uªº¥½ºÝÂI·í°µ Picture1 ªº¾î½u°_©lÂI
        For I = 0 To PicWidth - 1
            For J = 0 To PicHeight - 1
                SetPixel .hdc, J, I, _
                        GetPixel(Picture2.hdc, I, Abs(J - PicHeight) - 1)
            Next
        Next

        .AutoRedraw = False
        '§ó·sø¹Ï°Ï
        .Refresh
        .Visible = True
        Picture2.Picture = .Image
        'ªÀ±N¹Ï°Ï¼e°ª«×Àx¦s¥H³Æ¤U¦¸§Q¥Î
        PicWidth = Picture1.ScaleWidth
        PicHeight = Picture1.ScaleHeight
        ReDraw = False
    End With
End Sub
'°f®É°w 90 ¶s
Private Sub Command4_Click()
Dim I As Integer, J As Integer
    With Picture1
        .Width = ScaleX(PicHeight, vbPixels, Me.ScaleMode) + TransX
        .Height = ScaleY(PicWidth, vbPixels, Me.ScaleMode) + TransY
        ReDraw = True
        .Visible = False
        .AutoRedraw = True

        '­ì²z¡G§â Picture2 ¶}©lÁa½u·í°µ Picture1 ªºµ²§ô¾î½u
        For I = 0 To PicWidth - 1
            For J = 0 To PicHeight - 1
                SetPixel .hdc, J, Abs(I - PicWidth) - 1, _
                        GetPixel(Picture2.hdc, I, J)
            Next
        Next

        .AutoRedraw = False
        .Visible = True
        .Refresh
        Picture2.Picture = .Image
        PicWidth = Picture1.ScaleWidth
        PicHeight = Picture1.ScaleHeight
        ReDraw = False
    End With
End Sub
Private Sub Form_Load()
    Command1.Caption = "¤ô¥­Â½Âà"
    Command2.Caption = "««ª½Â½Âà"
    Command3.Caption = "¶¶®É°w 90"
    Command4.Caption = "°f®É°w 90"

    With Picture2
        '¨Ï Picture2 ¾AÀ³¹ÏÀɤj¤p
        .AutoSize = True
        .Picture = LoadPicture("c:\temp\1.1.jpg")
        '¨Ï Picture1 »P Picture2 ¦P¤j¤p
        Picture1.Width = .Width
        Picture1.Height = .Height
        '³æ¯Â¬°¹Ï¯À·|¥[§Ö´yÂIø¹Ï
        .ScaleMode = 3
        'Àx¦s Picture ¼e°ª«×
        PicWidth = .ScaleWidth
        PicHeight = .ScaleHeight
        .Visible = False
        '¥´¶} AutoRedraw ¤~¯à¨ú±o Visible = False ªº¹ÏÂI
        .AutoRedraw = True
    End With

    With Picture1
        'Àx¦sÃä¬É Twip ­È¥H¨Ñ½Õ¾ã¹Ï§Î¤j¤p¤§¥Î
        TransX = .Width - .ScaleWidth
        TransY = .Height - .ScaleHeight
        .ScaleMode = 3
    End With

End Sub
Private Sub Picture1_Paint()
    '¦pªG¤£¬O¦b±ÛÂ୫ø°Ê§@¤¤«h­«Ã¸¹Ï«¬
    If Not ReDraw Then
        With Picture1
            .PaintPicture Picture2.Image, 0, 0, PicWidth, PicHeight, _
                    0, 0, PicWidth, PicHeight
        End With
    End If
End Sub

¦^¯Á¤Þ


¦r¦ê¹ï»ô¿é¥X


  1. ¤À´²¹ï»ô¿é¥X¡G
    'Windows ¦r«¬¦b¦C¦L®É¡A±`¬°Äæ¦ì¹ï»ô¦Ó­W¡A¦]¬°´Nºâ¦r¦ê¦r¼Æ§¹¥þ¤@¼Ë¡A
    '¤]¥i¯à¦]­Ó§O¦r¤¸¼e¯¶¤£¦P¡A¦Ó³y¦¨¦r¦ê¿é¥X¼e¯¶¤£¦P(³Ì©úÅ㪺¨Ò¤l¬OªÅ¥Õ¦r¤¸)¡C
    '´N¦]¬°¦¹ºØ¯S©Ê¡A¨Ï±o¥H©¹¦b Dos ®É¥N¡A¥ÎªÅ¥Õ¦r¤¸¸É»ô¦r¦êªø«×¡A¥H¨D¿é¥X
    'Äæ¦ì¹ï»ôªº¤è¦¡Åܪº¤£¥i¦æ¡A¦]¦¹¸Ô²Ó­pºâ¿é¥Xª«¥óªº®y¼Ð¡A²¾°Ê¿é¥Xªº¥Ø«e¦ì¸m¦A
    '¥[¥H¿é¥X¡AÁöµM¬O¤@¥ó­W®t¡A¦ý¬°¨D¿é¥Xªº·Ç½T¡A¦ü¥G¬O§K¤£¤Fªº¨Æ¡C
    '¥»½d¨Ò´N¦b®i¥Ü¦p¦ó§Q¥Î VB ¿é¥Xª«¥óªº CurrentX,CurrentY ÄݩʡA¹F¦¨©Ò¦³¿é¥X
    '¦r¦êµe­±ªø«×¤@¼Ë¡A¨Ã¦³ Word ±`¥Î "¤À´²¹ï»ô" ®æ¦¡ªº®ÄªG¡C

    '´ú¸Õ¥»½d¨Ò¡A½Ð©ó Form ¤W¥¬¸m Command1¡BPicture1

    Option Explicit
    Private Sub Command1_Click()
    Dim SendArray(2) As String
    Dim I As Byte

        SendArray(0) = "1234567890"
        SendArray(1) = "VB 6.0 °Ý¥@"
        SendArray(2) = "ªø«×¬Û¦Pªº¦r¦ê¿é¥X"

        For I = 0 To 2
            '³v¤@§â¦r¦ê°}¦C°e©¹¦r¦ê¿é¥X¦Û­q¨ç¼ÆÅã¥Ü¡A
            '¨ú¦rªø«×¬O 10 ­Ó¤¤¤å¦r
            FixWidthString 10, SendArray(I)
        Next
    End Sub
    '¤À´²¹ï»ô¿é¥X¦Û­q¨ç¼Æ
    'StringLength ¨ú¦rªø«×
    'AcceptString ¹ï»ô¦r¦ê
    Private Sub FixWidthString(ByVal StringLength As Integer _
            , ByVal AcceptString As String)
    '­pºâ¨ú¦r¦³¦h¼eªº¦r¦êÅܼÆ
    Dim CalcString As String
    '¨â¦r¶¡¹jªº¼e«×
    Dim SepWidth As Single
    Dim I As Integer
    'Àx¦s¤W¦¸¿é¥Xªºµ²§À¦ì¸m
    Dim oldY As Single, oldX As Single

        '±µ¦¬¦r¦ê¤ñ¨ú¦rªø«×ªø«hºIÂ_
        If Len(AcceptString) > StringLength Then
            AcceptString = Left(AcceptString, StringLength)
        End If

        '±N¨ú¦rÅܼƶñº¡¤¤¤å¦r
        CalcString = String(StringLength, "°ê")
        '­pºâ¨â¦r¶¡¹jªº¼e«×¡A­ì²z¬O¨ú¦rÅܼƤñ¶Ç¤J¦r¦ê¦h¥Xªºªø«×¡A
        '­n¥­§¡´¡¤J¨â¦r¶¡¹j¤¤
        SepWidth = (Picture1.TextWidth(CalcString) - _
                Picture1.TextWidth(AcceptString)) / _
                (Len(AcceptString) - 1)

        '°O¦í¿é¥X«eªº Y ®y¼Ð
        oldY = Picture1.CurrentY
        '¿é¥X²Ä¤@¦r
        Picture1.Print "[" & Mid(AcceptString, 1, 1)
        '´«ºâ±µÄò¿é¥Xªº X ®y¼Ð¬O¦h¤Ö
        oldX = oldX + Picture1.TextWidth("[" & Mid(AcceptString, 1, 1))

        For I = 2 To Len(AcceptString)
            '¦^¨ì¿é¥X«eªº Y ®y¼Ð
            Picture1.CurrentY = oldY
            '¿é¥X¦ì¸m¦V¥k²¾¤@ªÅ¥Õ¶¡¹j
            oldX = oldX + SepWidth
            '¿é¥X®y¼Ð²¾¨ì oldX
            Picture1.CurrentX = oldX
            Picture1.Print Mid(AcceptString, I, 1)
            '´«ºâ±µÄò¿é¥Xªº X ®y¼Ð¬O¦h¤Ö
            oldX = oldX + Picture1.TextWidth(Mid(AcceptString, I, 1))
        Next
        Picture1.CurrentY = oldY
        Picture1.CurrentX = oldX
        '"[" ©M "]" ¥D­n¬O¬°¤F¼Ð¥Ü¿é¥X¼e«×¡A¥¿¦¡¨Ï¥Î®É½Ð®³±¼¡C
        Picture1.Print "]"
    End Sub
  2. ¦V¥k¹ï»ô¿é¥X¡G
    '´ú¸Õ¥»½d¨Ò½Ð©ó Form ¤W¥¬¸m Picture1,Command1
    '±ý¨Ï¥Î©ó¦C¦L¡A±N¿é¥Xª«¥ó¥Ñ Picture Âà¦Ü Printer
    Option Explicit
    Private Sub Command1_Click()
        '¥H¤U¨â¦æ¬O§â¼Æ¦r¦b¥ªÃä¸É»ô¤­­Ó¦r¡A¦ý³Ì«á§A·|µoı³o¦b¿é¥X
        '¹ï»ô¤W¤@ÂI¥Î³£¨S¦³¡A¦]¬° Windows ¦r«¬¼e¯¶¤£¤@¡A¦P¼Ë¦r¼Æ¦r¦ê
        '¼e«×´N¬O¤£¤@¼Ë¡C
        Picture1.Print Right(Space(5) & Format(123, "###"), 5)
        Picture1.Print Right(Space(5) & Format(12, "###"), 5)

        '¤U­±¬O©I¥s¥k»ô¿é¥X¦Û­q¨ç¼Æ¡A¦¹¨ç¼Æ§¹¥þ©ñ±ó¤F¥H©¹ Dos ¸É¦r¼Æ¹ï»ô¦r¦ê
        'ªº¤èªk¡A¥H¹Ï§Î®y¼Ð´«ºâªº¤è¦¡¡A§â¤£µ¥ªø¦r¦ê©ñ¦b¤£¦P¦ì¸m¿é¥X¡A¹F¦¨¥k»ô
        '¿é¥Xªº¥Øªº¡C
        FixRightPrint CStr(123), 5
        FixRightPrint CStr(12), 5
        '¥Î "W" ¦r¤¸ªº¥Øªº¬O§i¶D§A¡A¦P¼Ë¬O­^¤å¦r¤¸¡A¦r¼e®t§O¦³¦h¤j¡C
        FixRightPrint "WWWWW", 5
    End Sub
    '¥k»ô¿é¥X¦Û­q¨ç¼Æ
    'PrintString ¬O±ý¥k»ô¿é¥X¤§¦r¦ê
    'PrintLength ¬O³]©w¿é¥X¤§³Ì¤j¦r¼Æ
    'StartPos ¬O³]©w¿é¥X®É¦V¥k°¾²¾¦r¼Æ¡A¬Ù²¤¬°¤£¥k²¾¡C
    '¥H¦r¼Æ´«ºâ¼e«×ªº·§©À¨Ó»¡¡A¥»²[¼Æ¥H¤j¼g "W" ¼e«×¬°³æ¦ì¡C
    Private Sub FixRightPrint(ByVal PrintString As String, _
            ByVal PrintLength As Integer, _
            Optional ByVal StartPos As Integer)
    'Áa¦X³Ì¤j¦r¼Æ¤Î°¾²¾¦r¼Æ¤§­pºâ¼e«×¦r¦ê
    Dim CalcWidthString As String
        '­pºâ¼e«×¦r¦êµ¥©ó³Ì¤j¦r¼Æ¥[°¾²¾¦r¼Æ
        CalcWidthString = String(PrintLength + StartPos, "W")
        '¥H³æ Byte ¦r¤¸¬°­pºâ°ò·Ç
        PrintString = StrConv(PrintString, vbFromUnicode)

        '¥u¨ú PrintLength ¦r¼Æ¿é¥X
        If LenB(PrintString) > PrintLength Then
            PrintString = LeftB(PrintString, PrintLength)
        End If

        'Á٭쬰Âù¦ì¤¸¦r
        PrintString = StrConv(PrintString, vbUnicode)

        With Picture1
            '²¾°Ê¿é¥X¤§ X ¶b
            .CurrentX = .TextWidth(CalcWidthString) - _
                    .TextWidth(PrintString)
        End With

        Picture1.Print PrintString
    End Sub

¦^¯Á¤Þ


Åý ChildForm ¶ñº¡ MDIForm


±H¥óªÌ: jessy

  1. §Úªº FORM ªº  Midchild ÄÝ©Ê= True¡A ¦pªG³]   BorderStyle = 1   ( or 3 )   «h©Ò³]­pªºµe­±¥i¥HÅã²{¥X¨Ó¡A¦ý¬ORuntime ®ÉµLªk¦A½Õ¾ãµe­±¤j¤p¡C
  2. ¦Ó BorderStyle = 2 , Runtime ®É©Ò³]­pªºµe­±µLªk§¹¥þÅã¥Ü¥X¨Ó,¦ý¥i¥H½Õ¾ã¤j¤p¡C
  3. ,¦p¦ó±N©Ò³]­pªºµe­±¯à§¹¥þÅã¥Ü¥X¨Ó¦Ó¥BÁÙ¥i½Õ¾ã¤j¤p ¡C

¦Ñ©Çµª¡G

±M®×Äݩʤ¤³] MDIForm ±Ò°Ê¡A¨Ã§â¤U¦C½X¶K MDIForm §Y¥i¡C
Private Sub MDIForm_Load()
    With Me
        .Show
        Load Form1
        Form1.Move 0, 0, .ScaleWidth, .ScaleHeight
        Form1.Show
    End With
End Sub

¦^¯Á¤Þ


Ãö³¬©Ò¦³µ{¦¡¸ü¤Jªºªí³æ


XXX ¼¶¼g©ó¤å³¹

½Ð°Ý­n¦p¦ó¥Î¤@­Ó«ü¥OÃö³¬µ{¦¡¤¤©Ò¦³ªº Form ?

¦Ñ©Çµª¡G

  1. ·íµM³Ìª½Ä±¦Ó²³æªº°µªk´N¬O¼g¤W End ±Ô­z¡A¦ý³o«o¬O«Ü¾D¿|ªº¤èªk¡C¦]¬°¥u­n VB ¸I¨ì End ±Ô­z¡A¥¦´N¤£·|°õ¦æ Form_UnLoad µ{§Ç¡A¦Óª½±µ¸õÂ÷¡C©Ò¥HÄÀ©ñ°O¾ÐÅé¡B²M°£ª«¥ó¡B¸ê®Æ¦^¼gºÏºÐ¤Î¸Ñ°£ÀÉ®×Âê©w¡A³o¨Ç­ì¥»ºD¨Ò©ñ¦b UnLoad µ{§Ç¤¤°õ¦æªº°Ê§@¡A³£°õ¦æ¤£¨ì¡A¦]¦¹³oºØµ{¦¡¨C°õ¦æ¤@¦¸¡A´N¶Ë®`¨t²Î¤@¦¸¡A¬Æ¦Ü¾É­P¨t²Î¥²¶·­«¶}¾÷¤~¯à«ì´_¥¿±`¡C
  2. ©Ò¥H°õ¦æ¤U¦Cµ{¦¡½X´N¥i¥HÅý¨Ï¥ÎªÌ¤U¤@¦¸«ü¥O¡A´NÃö³¬©Ò¦³ªº Form ¡A¨Ã¥B©Ò¦³ Form ªº UnLoad µ{§Ç³£°õ¦æªº¨ì¡G
    Dim CloseForm As Form

    For Each CloseForm In Forms
        Unload CloseForm
    Next
  3. ¦ý§Ú­ÌÁÙ¸Ó¦³­Ó»{ÃÑ¡A¨Ã¤£¬O UnLoad Form ¤§«á Form ¥²µM´N³QÄÀ©ñ¡A¦pªG SecondForm_UnLoad µ{§Ç¤¤¦³¡G
    Private Sub SecondForm_Unload(Cancel As Integer)
    If Not ½T©w²æÂ÷ Then
    Cancel = True
    End If
    End Sub
    ±Ô­z¡A¦Ó·í [½T©w²æÂ÷]= False ®É¡AForm ¤´µM¬OµLªk²æÂ÷ªº¡A¬°¤F¦b§Oªº Form ¤]¯àÃö±¼¦¹ Form ¡A«h [½T©w²æÂ÷] À³¦b¤@¯ë°Ï«Å§i¬° Public ¡A¤~¯à¦b§Oªº Form §Q¥Î FormName.½T©w²æÂ÷=True ±Ô­z¡A§âªí³æ³]¬°¯à²æÂ÷ªºª¬ªp¡C©Ò¥H²æÂ÷±Ô­zÀ³§ï¬°¡G
    Dim CloseForm As Form

    SecondForm.½T©w²æÂ÷=True
    For Each CloseForm In Forms
        Unload CloseForm
    Next

¦^¯Á¤Þ


¥Î±²¶b³]©wÃC¦â­È


  1. ¥»½d¨Ò¬O¥Î¤T­Ó±²¶b¨Ó§ïÅܦâ±m­Èùتº R¡BG¡BB ¤T­ì¦â¡A­«ÂI¬O§â Color ªºªø¾ã¼Æ­È(Long Type)¡A¤ÀÂ÷¦¨¤À§Oªº R¡BG¡BB Byte ­È(0~255)¡C
  2. °õ¦æ¥»½d¨Ò½Ð©óªí³æ¥¬¸m Label1¡BOption1,2¡BHScroll1,2,3¡C
  3. µ{¦¡½d¨Ò¦p¤U¡G
    Option Explicit

    Private Const ChangeFrontColor As Byte = 0
    Private Const ChangeBackColor As Byte = 1

    Private Sub Form_Load()
        Option1.Caption = "¤å¦r¦â±m"
        Option2.Caption = "­I´º¦â±m"
        Label1.ForeColor = RGB(0, 0, 0)
        Label1.BackColor = RGB(&HC0, &HC0, &HC0)

        HScroll1.Max = 255
        HScroll1.Min = 0
        HScroll1.LargeChange = 15
        HScroll1.SmallChange = 1

        HScroll2.Max = 255
        HScroll2.Min = 0
        HScroll2.LargeChange = 15
        HScroll2.SmallChange = 1

        HScroll3.Max = 255
        HScroll3.Min = 0
        HScroll3.LargeChange = 15
        HScroll3.SmallChange = 1
    End Sub

    Private Sub HScroll1_Change()
        ColorChange
    End Sub

    Private Sub HScroll1_Scroll()
        ColorChange
    End Sub

    Private Sub HScroll2_Change()
        ColorChange
    End Sub

    Private Sub HScroll2_Scroll()
        ColorChange
    End Sub

    Private Sub HScroll3_Change()
        ColorChange
    End Sub

    Private Sub HScroll3_Scroll()
        ColorChange
    End Sub

    Private Sub Option1_Click()
        SetScrollValue
    End Sub

    Private Sub Option2_Click()
        SetScrollValue
    End Sub

    '¸ò¾Ú HScroll.Value ­È¨Ó³]©w Label Color ªº¦Û­q¨ç¼Æ
    Private Sub ColorChange()
        If Option1 Then
            Label1.ForeColor = RGB(HScroll1.Value, _
                    HScroll2.Value, HScroll3.Value)
        Else
            Label1.BackColor = RGB(HScroll1.Value, _
                    HScroll2.Value, HScroll3.Value)
        End If
    End Sub

    '¸ò¾Ú Label Color ­È¨Ó³]©w HScroll.Value ªº¦Û­q¨ç¼Æ
    Private Sub SetScrollValue()
    Dim LongColor As Long

        If Option1 Then
            LongColor = Label1.ForeColor
        Else
            LongColor = Label1.BackColor
        End If

        HScroll1.Value = LongColor Mod 256
        LongColor = LongColor \ 256
        HScroll2.Value = LongColor Mod 256
        LongColor = LongColor \ 256
        HScroll3.Value = LongColor Mod 256
    End Sub

¦^¯Á¤Þ


¤½¤åµ²®×¤é­pºâ½d¨Ò


±H¥óªÌ: Jeff Chen

§Ú·Q³]­p¤@µ{¦¡¥Î¥H­pºâ¤½¤åªº¿ì²z®É¶¡,³W©w¬O³Ì³t¥ó¤@¤Ñ,³t¥ó¤T¤Ñ,´¶³q¥ó¤C¤Ñ,¦ý¬O»Ý¸ó¹L°²¤é(°ê©w°²¤é¤Î¶g¥ð¤G¤é) ½Ð°Ý­n¦p¦ó­pºâ¥X,À³¸Ó¿ì§¹ªº¤é´Á.

¦Ñ©Çµª¡G

Option Explicit

'§ä¬Y¤@­Ó¶g¤»¤é´Á°µ¬°±Àºâ¶g¥ð¤G¤éªº°ò·Ç¤é´Á
Private Const ¶g¤»°ò·Ç¤é As Date = #1/3/98#

'¦pªG°ò·Ç¤é´Á¬O¥ð°²ªº«h¦¹±`¼Æ¬° 0 ¡A§_«hÀ³§ï¬° 1¡C
Private Const ¶g¥ð¤G¤é As Byte = 0

'©ñ©Ò¦³°ê©w°²¤éªº¤é´Á°}¦C
Dim °²¤é°}¦C() As Date

'¥»¨ç¼Æ¬O¥Î¨Ó¬d®Ö¬Y¤é´Á¬O§_¬°©ñ°²¤é¡A¨ä·Ç«h¦³¤T¡G
'¬P´Á¤é«h¥»¨ç¼Æµ¥©ó True
'¶g¥ð¤G¤éªº¬P´Á¤»«h¥»¨ç¼Æµ¥©ó True
'¯S©w¨Ò°²¤é«h¥»¨ç¼Æµ¥©ó True
Private Function °²¤é¬d®Ö(ByVal CheckDay As Date) As Boolean
Dim I As Integer
Dim ¬O§_°²¤é As Boolean

    '¦pªG¬P´Á¤é«h¥»¨ç¼Æµ¥©ó True
    If WeekDay(CheckDay) = vbSunday Then
        ¬O§_°²¤é = True
    '¦pªG«D¬P´Á¤é
    Else
        '¦pªG¬P´Á¤»
        If WeekDay(CheckDay) = vbSaturday Then
            '¯S©w¤é´Á´î¥h°ò·Ç¤é´Á°£¥H¤C¡A¬Oªí¥Ü¶ZÂ÷°ò·Ç¤é´Áªº²Ä´X¶g¡C
            '±N²Ä´X¶g¼Æ¥Ø¨ú 2 ªº¾l¼Æ´N¥i¥H§PÂ_¶g¥ð¤G¤éªº½ü´À¡C
            If Int((CheckDay - ¶g¤»°ò·Ç¤é) / 7) Mod 2 = ¶g¥ð¤G¤é Then
                ¬O§_°²¤é = True
            End If
        End If

        '³Ì«á¬O§â©Ò¦³«D¶g¥ð¤G¤éªº¬P´Á¤»¤Î¨ä¥L¤é´Á¡A¨Ì§Ú­Ì¦b
        '[¨ä¥L¨Ò°²¤é] Sub ¤¤©ñ¤Jªº°²¤é°}¦C¨Ó§PÂ_¬O§_°ê©w°²¤é¡C
        If Not ¬O§_°²¤é Then
            For I = 0 To UBound(°²¤é°}¦C)
                If CheckDay = °²¤é°}¦C(I) Then
                    ¬O§_°²¤é = True
                    Exit For
                End If
            Next
        End If
    End If

    °²¤é¬d®Ö = ¬O§_°²¤é
End Function

Private Sub ¨ä¥L¨Ò°²¤é()
    ReDim °²¤é°}¦C(2)

    '±N°ê©w°²¤é¥H¦CÁ|¤è¦¡¤@¤@©ñ¤J°}¦C¤¤¡A½Ð¦Û¦æ¸É¨¬¤£¨¬¶µ¥Ø
    °²¤é°}¦C(0) = DateSerial(Year(Date), 3, 29)     '«C¦~¸`
    °²¤é°}¦C(1) = DateSerial(Year(Date), 10, 10)    '°ê¼y¤é
    °²¤é°}¦C(2) = DateSerial(Year(Date), 12, 25)    '¦æ¾Ë¬ö©À¤é
End Sub

Private Sub Form_Click()
Dim CalcDay As Date

    'ÀH«K¿ï¤@¤é´ú¸Õ
    CalcDay = #11/20/98#
    CalcDay = µ²®×¤é(CalcDay, 7)
    Debug.Print CalcDay
End Sub

Private Sub Form_Load()
    '°õ¦æ©ñ¤J°²¤é¦Û­qµ{§Ç
    ¨ä¥L¨Ò°²¤é
End Sub

Private Function µ²®×¤é(ByVal ¦¬¥ó¤é As Date, _
        ByVal ¿ì²z¤é¼Æ As Integer) As Date
Dim RetrunDay As Date
'I ¬O°²¤é¬d®Ö«ü¼Ð¡AJ ¬O¹ê»Ú¤u§@¤Ñ¼Æ²Ö­p¡C
Dim I As Integer, J As Integer
    If ¿ì²z¤é¼Æ < 1 Then
        MsgBox "¿ì²z¤é¼Æ³Ì¤Ö¬°¤@¤Ñ"
        Exit Function
    End If

    Do While J < ¿ì²z¤é¼Æ
        I = I + 1
        If Not °²¤é¬d®Ö(¦¬¥ó¤é + I) Then
            J = J + 1
            µ²®×¤é = (¦¬¥ó¤é + I)
        End If
    Loop
End Function

¦^¯Á¤Þ


VB ¤p¾xÄÁ½d¨Ò


VERSION 5.00
Begin VB.Form Form1
   Caption         =   "Form1"
   ClientHeight    =   3195
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   3840
   LinkTopic       =   "Form1"
   ScaleHeight     =   3195
   ScaleWidth      =   3840
   StartUpPosition =   3  '¨t²Î¹w³]­È
   Begin VB.CommandButton Command1
      Caption         =   "Command1"
      Height          =   495
      Left            =   2280
      TabIndex        =   2
      Top             =   2400
      Width           =   1215
   End
   Begin VB.Frame Frame1
      Caption         =   "Frame1"
      Height          =   1935
      Left            =   240
      TabIndex        =   1
      Top             =   1080
      Width           =   1575
      Begin VB.TextBox Text1
         Height          =   270
         Index           =   2
         Left            =   600
         TabIndex        =   8
         Text            =   "Text1"
         Top             =   1320
         Width           =   615
      End
      Begin VB.TextBox Text1
         Height          =   270
         Index           =   1
         Left            =   600
         TabIndex        =   6
         Text            =   "Text1"
         Top             =   840
         Width           =   615
      End
      Begin VB.TextBox Text1
         Height          =   270
         Index           =   0
         Left            =   600
         TabIndex        =   4
         Text            =   "Text1"
         Top             =   360
         Width           =   615
      End
      Begin VB.Label Label2
         Caption         =   "Label2"
         Height          =   255
         Index           =   2
         Left            =   240
         TabIndex        =   7
         Top             =   1320
         Width           =   615
      End
      Begin VB.Label Label2
         Caption         =   "Label2"
         Height          =   255
         Index           =   1
         Left            =   240
         TabIndex        =   5
         Top             =   840
         Width           =   615
      End
      Begin VB.Label Label2
         Caption         =   "Label2"
         Height          =   255
         Index           =   0
         Left            =   240
         TabIndex        =   3
         Top             =   360
         Width           =   615
      End
   End
   Begin VB.Timer Timer1
      Left            =   3120
      Top             =   360
   End
   Begin VB.Shape Shape1
      Height          =   255
      Left            =   2040
      Shape           =   3  '¶ê§Î
      Top             =   480
      Width           =   255
   End
   Begin VB.Label Label1
      Caption         =   "Label1"
      Height          =   495
      Left            =   360
      TabIndex        =   0
      Top             =   360
      Width           =   2055
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim SetTime As Date
Private Sub Command1_Click()
    If Command1.Caption = "³]©w®É¶¡" Then
        Frame1.Visible = True
        Command1.Caption = "½T©w®É¶¡"
    Else
        Frame1.Visible = False

        If Val(Text1(0).Text) > 24 Then Text1(0).Text = 24
        If Val(Text1(1).Text) > 60 Then Text1(1).Text = 60
        If Val(Text1(2).Text) > 60 Then Text1(2).Text = 60

        If Text1(0).Text = "" Then Text1(0).Text = 0
        If Text1(1).Text = "" Then Text1(1).Text = 0
        If Text1(2).Text = "" Then Text1(2).Text = 0

        SetTime = TimeSerial(Val(Text1(0).Text), Val(Text1(1).Text), _
                Val(Text1(2).Text))
        Command1.Caption = "³]©w®É¶¡"
        Debug.Print SetTime
    End If
End Sub
Private Sub Form_Load()
    Timer1.Interval = 1000
    Label1.BackColor = RGB(125, 0, 255)
    Label1.ForeColor = RGB(0, 255, 255)
    Label1.FontSize = 24

    Shape1.FillStyle = 0
    Shape1.FillColor = RGB(0, 255, 0)

    Frame1.Caption = "½Ð¿é¤J¤é´Á"
    Frame1.Visible = False

    Label2(0).Caption = "®É"
    Label2(1).Caption = "¤À"
    Label2(2).Caption = "¬í"

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

    Command1.Caption = "³]©w®É¶¡"

    ShowTime
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
Private Sub Timer1_Timer()
    ShowTime
End Sub
Private Sub ShowTime()
Dim SubTime As Date
    Shape1.FillColor = RGB(0, 255, 0)
    SubTime = TimeSerial(Hour(Now), Minute(Now), Second(Now))
    Label1.Caption = SubTime

    '¦b®É¶¡¨ì¹F«áªº¤»¬í¡A·|¦³´£¿ô¿O¸¹¤ÎÁn­µ
    If SubTime > SetTime And SubTime < TimeSerial(Hour(SetTime), _
            Minute(SetTime), Second(SetTime) + 6) Then
        Shape1.FillColor = RGB(255, 0, 0)
        Beep
    End If
End Sub

¦^¯Á¤Þ


³Ì§Öªº¶}ÀɼҦ¡


¦w¦w ¼¶¼g©ó¤å³¹

§Ú¦pªG¶}±Ò¤@­Ó¶W¹L1mb®e¶qªº¤å¦rÀÉ,³£·|ı±o«ÜºC!½Ö¥i¥H§Ú«ü¾É¤@¤U,¶}±ÒÀɮתº¤@¨Ç§Þ¥©©O?

¦Ñ©Çµª

  1. ´N§Ú­Ó¤H¦b VB ¹ê§@¤W¡AFile I/O ªº Open Mode ¡AInput¡BRandom¡BBinary ùØ¡A¥H Binary Mode ªº³t«×³Ì§Ö¡A©Ò¥H§Ú¬° VB ¤Í¤¶²Ðªº§Ö³t¶}Àɤ覡³£¬O¡G
    Option Explicit

    Dim FileHandle As Integer
    Dim Buff() As Byte
    Dim LongString As String

        FileHandle = FreeFile
        Open "YourFilePath&Name" For Binary As #FileHandle
        ReDim Buff(LOF(FileHandle) - 1)
        Get #FileHandle, , Buff
        Close #FileHandle
  2. ¨º«ç»òÂন¤å¦r¼Ò¦¡©O¡H«Ü²³æ¡A
  3. ¦b¥H©¹§Ú³£¨S¦³¸ÑÄÀ¬°¦ó Binary Mode ³Ì§Ö¡A¦b³oùاڷQ¸ÑÄÀ¤@¤U¡A¦pªG¤£¹ï¡A½Ð¤j®a«ü¥¿¡C
  4. §Ú­Ì¥Î Input Mode ¶}ÀÉ¡A«h¬O§Q¥Î°j°é¥H Input #FileHandle,Var1,Var2,Var3 Ū¤JÀɮסA©Î¥H Line Input #FileHandle,VarString Ū¤JÀɮסA¤£ºÞ¬O Input # or Line Input # ³¯­z¦¡¡AŪÀɪº°Ê§@³£¬O§âÀɮ׳v¦r¤ñ¹ï¡A¹J¨ì "," ¤Î VbCrLf ¦r¤¸¡A«h¤Á³ÎŪ¤J¦r¤¸¡A©ñ¤JÅܼƤ¤¡C©Ò¥H§A¦³ 1 Mega ¤j¤pÀɮסA¥¦´N¥²¶·Åª¨ú¤ñ¹ï 1 Mega ¦¸¡C
  5. Random ¼Ò¦¡«h¦n¤@ÂI¡A¥L¥H©T©w°O¿ýªø«×Ū¨ú¸ê®Æ¡A¤]´N¬O¥¦¤£·|°µ³v¦r¤ñ¹ïªº¤u§@¡A¦Ó¬O¤@¦¸§ì°O¿ýªø«×ªº¦r¦ê¨ì°O¾ÐÅéùØ¡A¦A°µ¸ê®Æªº¤À°t¡A¨ä¤¤¦³µL¤À¹j¦r¤¸©Î¤À¦æ²Å¸¹¡A¥¦¬O¤@·§¤£ºÞªº¡C
  6. Binary ©M Random Ū¨úÀɮתº°ò¥»­ì²z¬O¬Û¦Pªº¡A¨º´N¬OŪ¨ú©T©wªø«×¸ê®Æ¦Ó¤£°µ³v¦r¤ñ¹ï¡C¦ý Random ¬O¥H¦Û­q«¬ºAÅܼƪø«×¡A°t¦X°j°é¡A¤À¬qŪ¨úÀɮסC¦Ó Binary «h¬O¥Ñ§A¦Û¦æ«ü©w±µ¦¬ÀÉ®×¸ê®Æ ByteArray ªºªø«×¡A§¹¥þ¤£§Q¥Î°j°é¡A¤@¦¸Åª¶i¨Ó¡CByteArray µu©ó File Length ¡A«h¥uŪ¨ú³¡¥÷¡A­Yªø©ó File Length¡A«h¤£¨¬³¡¥÷ ByteArray ­È¬O 0¡A­nª`·Nªº¬O Chr(0)<>"" ¡AChr(0) ¤´¦û¦³¦r¦êªø«×¡A¦b°µ¦r¦êÂà´«®É­nª`·N¡C¤]¦]¬° Binary ¬O¤@¦¸Åª¨ú¡A©Ò¥H¦b¥þÀÉŪ¨ú¤W¡A®Ä²v¤ñ Random ªº¤À¬qŪ¨ú­n¦n¡C
  7. ¦b§Ú­è¾Ç·| Binary Open Mode ¡A¤]¶¶§Qªº¥Î ByteArray Åܼƨú¦^ÀÉ®×¸ê®Æ«á¡A§Ú´¿¦nªø¤@¬q®É¶¡¥Î¤U¦C²Â²Âªº¤èªk±N ByteArray ¥Î¤U¦C¤è¦¡Âন¦r¦ê¡G
    For I=0 To Ubound(Buff)
    LongString=LongString + Chr(Buff(I))
    Next
    ¦]¬° Byte »P String Åܼƫ¬ºA¤£¦P¡A«ö¹D²zÀ³¸Ó³z¹LÂà´«¨ç¼Æ°Ú¡A©Ò¥H§Ú¤´¬Oºâ¤F 1 Mega ¦¸¡C
  8. ª½¨ì§Ú¬Ý¨ì¤F§O¤H¥Î LongString =Buff ³oºØª½±µÂà´«ªº½d¨Ò¡A¤Sª¾¹D¤F Windows OS ¦b³B²z°O¾ÐÅé°ïÅ|¦³¤@­Ó AddressOf() ¨ç¼Æªº¥\¯à(VB ¨S¦³¶}©ñ¦¹¨ç¼Æ¨Ï¥Î)¡Aª¾¹D­n¾ã§å¨ú±o°}¦C¸ê®Æ¡A¥i¥H¤£¥Î°}¦C«ü¼Ð³vµ§¯Á¤Þ¡A¦Ó¬O¨ú±o°}¦C¶}©l°O¾ÐÅé¦ì¸m«á¡A¤@¦¸Åª¨ú¾ã­Ó°}¦Cªø«×ªº¸ê®Æ¨ì¦r¦êÅܼÆùØ¡A¦]¦¹§Ú²q LongString=Buff ªº±Ô­z¡A´N¬OÅý VB ±Ò¥Î AddressOf() ªº¥\¯à¡A¤@¦¸§â¾ã­Ó Buff °}¦C¤@¦¸©ñ¤J LongString ¦r¦êÅܼÆùØ¡C¦]¦¹ Binary ¤§©Ò¥H§Öªº­ì²z´N¬O¨ú±oºÏºÐÀɮתº¶}©l¦ì¸m¡A¤£¸g¥ô¦ó¤ñ¹ï¡A¤@¦¸¨ú¥X©T©wªø«×¸ê®Æ¨ì°O¾ÐÅé¡A¦A¦b­p¾ÐÅ餤§ä¨ì°}¦C°O¾ÐÅé¦ì§}¡A¤@¦¸Åª©T©wªø«×¨ì StringVariant ¤¤¡A¥Îªººtºâ«Ü¤Ö¡A¦ÛµM³t«×­¸§Ö¡C
  9. Binary ¥i¥H»¡¬O³Ì­ì©lªºÀÉ®×Ū¨ú«¬ºA¡A¦]¬°¥¦¤£°õ¦æ¤À¦æ¤ÀÄæªº¥\¯à¡A©Ò¥H§Ú­Ì±o¦Û¦æ¹ïŪ¤J¸ê®Æ¥[¥H¤À¦æ¤ÀÄæ¡C
  10. ¦Ü©ó°O¾ÐÅé¸ê®Æªº¿é¥X¡A¦pªG¬O«D¤å¦rªº¤G¶i¦ìÀÉ¡A¨º·íµMÁÙ¬O±o¥Î Binary ¤è¦¡¿é¥X¡A¦Ü©ó¤å¦rÀÉ¡A¥Ñ©ó´Nºâ¥Î Bianry ¿é¥X¡A§Ú­ÌÁÙ¬O±o¥ý³v¦æ³vµ§¥[¤J¤ÀÄæ¤À¦æ¸ê®Æ¨ì Byte °}¦CùØ¡A¤~·|¦s¦¨¥¿½Tªº¤å¦rÀɮ榡¡A©Ò¥H¥Î Output¡BAppend¡BRandom »P Binary ³t«×©Ò®tµL´X¡A¦ý«o¤ñ Binary ¤è«K«Ü¦h¡C

¦^¯Á¤Þ


«ç¼ËÂI¨ú Disable ªºª«¥ó


XXX ¼¶¼g©ó¤å³¹

§Ú¦b¤@­ÓForm¤¤Â\¤F­Ó Frame¡A§Ú¦bForm Load®É ±N Frame Disable¡A§Ú·QÅý·Æ¹«¦bFrame¤WÂI¤@¤U,¤~Enable³QÂI¨ìªºFrame¡A¦]¬°Frame¥¼Enable«eµLªk±µ¨ü¥ô¦ó¨Æ¥ó¡A­n¦p¦ó¤~¯à°µ¨ì©O?

¦Ñ©Çµª¡G

ÁöµM Frame1.Visible=False «á¡AForm ¤WÁ٬ݱo¨ì Frame1 ²H¦Ç¦â¼v¹³¡A¦ý·í§Ú­Ì MouseClick «á¡A¦¬¨ì Mouse Event ªº«o¬O Frame ­I«áªºª«¥ó¡A©Ò¥H¦pªG Frame1 «á­±´N¬O Form ªº¸Ü¡A¥i¥H¨Ï¥Î Form ¨Ó±µ¦¬ Mouse Event ¡A¨Ã¨Ï Frame1.Enable=True¡G
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    With Frame1
        If (X > .Left And X < .Left + .Width) And (Y > .Top And Y < .Top + .Height) Then
            .Enabled = True
        End If
    End With
End Sub

¦^¯Á¤Þ


¹Ï¤ù±²°Ê²°½d¨Ò


ÂŦâ°{ÆF ¼¶¼g©ó¤å³¹

¦p¦ó¤~¯à§Q¥Î¤ô¥­©M««ª½½Õ¸`¶s¨Ó±±¨î¹Ï¤ù¤è¶ô¸Ìªº¹Ï¤ù§r?

¦Ñ©Çµª¡G

  1. ½d¨Ò¥\¯à¡G
  2. ½d¨Òµ{¦¡½X¡G
    VERSION 5.00
    Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "COMDLG32.OCX"
    Begin VB.Form Form1
       Caption         =   "Form1"
       ClientHeight    =   3750
       ClientLeft      =   165
       ClientTop       =   735
       ClientWidth     =   5235
       LinkTopic       =   "Form1"
       ScaleHeight     =   3750
       ScaleWidth      =   5235
       StartUpPosition =   3  '¨t²Î¹w³]­È
       Begin MSComDlg.CommonDialog CommonDialog1
          Left            =   3720
          Top             =   1920
          _ExtentX        =   847
          _ExtentY        =   847
          _Version        =   327680
       End
       Begin VB.HScrollBar HScroll1
          Height          =   255
          Left            =   960
          TabIndex        =   2
          Top             =   2880
          Width           =   1335
       End
       Begin VB.VScrollBar VScroll1
          Height          =   1335
          Left            =   4560
          TabIndex        =   1
          Top             =   480
          Width           =   255
       End
       Begin VB.PictureBox Picture1
          Height          =   2055
          Left            =   240
          ScaleHeight     =   1995
          ScaleWidth      =   2475
          TabIndex        =   0
          Top             =   360
          Width           =   2535
          Begin VB.Image Image1
             Height          =   615
             Left            =   960
             Top             =   480
             Width           =   1215
          End
       End
       Begin VB.Menu mnuFile
          Caption         =   "ÀÉ®×(&F)"
          Begin VB.Menu mnuOpenFile
             Caption         =   "¶}±Ò¹ÏÀÉ(&O)"
          End
          Begin VB.Menu mnuQuitApp
             Caption         =   "µ²§ô(&Q)"
          End
       End
       Begin VB.Menu mnuView
          Caption         =   "À˵ø(&V)"
          Begin VB.Menu mnuZoomIn
             Caption         =   "©ñ¤j(&I)"
          End
          Begin VB.Menu mnuZoomOut
             Caption         =   "ÁY¤p(&S)"
          End
          Begin VB.Menu mnuReset
             Caption         =   "ÁÙ­ì(&R)"
          End
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    '°õ¦æ¥»½d¨Ò­n°O±o¤Þ¥Î CommonDialog ª«¥ó¡A¨Ã¥¬¸m¨ìªí³æ¤W¡C
    Option Explicit
    '°O¿ý­ì¹Ï¤ùªø¼e
    Dim OPicWidth As Single, OPicHeight As Single
    '¹Ï¤ùÁY©ñ¤ñ
    Dim ViewRate As Single
    Private Sub Form_Load()
        Me.Caption = "²©ö¹Ï¤ù±²°Ê²°:"
       
        '³]©wÀÉ®×¹ï¸Ü²°¤§±Ò©l¸ô®|¬°°õ¦æµ{¦¡¸ô®|
        CommonDialog1.InitDir = App.Path
       
        '³]©w CommonDialog ªº Filter ¬° VB ¤ä´©¤§¹ÏÀɮ榡
        CommonDialog1.Filter = "©Ò¦³¹ÏÀÉ|*.bmp;*.dib;*.ico;*.wmf;*.emf;*.jpg;*.gif|" & _
                "Windows ¼Ð·Ç¹ÏÀÉ(*.bmp;*.dib)|*.bmp;*.dib|" & _
                "¹Ï¥ÜÀÉ(*.ico)|*.ico|¦V¶qÀÉ(*.wmf;*.emf)|*.wmf;*.emf|" & _
                "JPeg À£ÁY¹ÏÀÉ(*.jpg)|*.jpg|Gif ¹ÏÀÉ(*.gif)|*.gif"
        
        '§â¹Ï¤ù²°³æ¦ì³]¬° Pixel ¡AÁ×§K¶W¹L Scroll ³]©w³Ì¤j´Ó
        Picture1.ScaleMode = 3
       
        '¹Ï¤ùÁY©ñ¤@¤ñ¤@
        ViewRate = 1
    End Sub
    Private Sub Form_Resize()
        '½Õ¾ã Scroll ¦ì¸m¤Î¹Ï¤ù²°¤j¤p
        With Me
            HScroll1.Move .ScaleLeft, .ScaleHeight - HScroll1.Height, _
                    .ScaleWidth - VScroll1.Width, HScroll1.Height
            VScroll1.Move .ScaleWidth - VScroll1.Width, .ScaleTop, _
                    VScroll1.Width, .ScaleHeight - HScroll1.Height
            Picture1.Move .ScaleLeft, .ScaleTop, _
                    .ScaleWidth - VScroll1.Width, .ScaleHeight - HScroll1.Height
        End With
       
        '³]©w Scroll ±²°Ê­È
        HScroll1.LargeChange = 25
        HScroll1.SmallChange = 1
        VScroll1.LargeChange = 25
        VScroll1.SmallChange = 1
       
        '­«³] Scroll ³Ì¤j³Ì¤p½d³ò
        ResetScrollValue
    End Sub
    Private Sub HScroll1_Change()
        '²¾°Ê¹Ï¤ù¦ì¸m
        ReSetImagePosition
    End Sub
    Private Sub HScroll1_Scroll()
        ReSetImagePosition
    End Sub
    '§Q¥ÎÀÉ®×¶}±Ò¹ï¸Ü²°¶}±ÒÅã¥Ü¹Ï¤ù
    Private Sub mnuOpenFile_Click()
        CommonDialog1.filename = ""
        CommonDialog1.ShowOpen
        If CommonDialog1.filename <> "" Then
            With Image1
                '¥ýÃö±¼ Image ªº Stretch ¥\¯à¥H¨ú±o¹Ï¤ù¤j¤p
                .Stretch = False
                .Picture = LoadPicture(CommonDialog1.filename)
                OPicWidth = .Width
                OPicHeight = .Height
                '¦A¶}±Ò Image ªº Stretch ¥\¯à¤~¯àÁY©ñ¹Ï¤ù
                .Stretch = True
            End With
            '­«³]¨ú¹Ï¸ô®|
            CommonDialog1.InitDir = CutImagePath(CommonDialog1.filename)
            '­«³] Scroll ³Ì¤j³Ì¤p­È
            ResetScrollValue
        End If
    End Sub
    Private Sub mnuQuitApp_Click()
        Unload Me
    End Sub
    '¨Ì Scroll ­È²¾°Ê¹Ï¤ù
    Private Sub ReSetImagePosition()
        With Image1
            .Move HScroll1.Value, VScroll1.Value
        End With
    End Sub
    Private Sub ResetScrollValue()
    Dim Offset As Long
      
        With HScroll1
            .Enabled = True
            Offset = (Picture1.ScaleWidth - Image1.Width) / 2
            '·í¹Ï¤ù¤ñ¹Ï¤ù²°¤p®É¨ú®ø Scroll ¥\¯à
            If Offset > 0 Then
                .Enabled = False
            End If
            .Min = 0
            '½Ðª`·N¡A·í³]©w Scroll ªº Max ©M Value ­È®É³£·|¦Û°ÊIJµo
            'Scroll_Change ¨Æ¥ó
            .Max = Offset * 2
            .Value = Offset
        End With
       
        With VScroll1
            .Enabled = True
            Offset = (Picture1.ScaleHeight - Image1.Height) / 2
            If Offset > 0 Then
                .Enabled = False
            End If
            .Min = 0
            .Max = Offset * 2
            .Value = Offset
        End With
    End Sub
    Private Sub mnuReset_Click()
        'ÁÙ­ì¹Ï¤ùÁY©ñ
        With Image1
            .Width = OPicWidth
            .Height = OPicHeight
        End With
        ViewRate = 1
        ResetScrollValue
       
        '«ì´_©Ò¦³ÁY©ñ¥\¯à
        mnuZoomIn.Enabled = True
        mnuZoomOut.Enabled = True
    End Sub
    Private Sub mnuZoomIn_Click()
        If ViewRate >= 8 Then
            '·í¶W¹L 8 ­¿«h°±¤î©ñ¤j
            mnuZoomIn.Enabled = False
        Else
            ViewRate = ViewRate + 0.25
            With Image1
                .Width = OPicWidth * ViewRate
                .Height = OPicHeight * ViewRate
            End With
            ResetScrollValue
        End If
        mnuZoomOut.Enabled = True
    End Sub
    Private Sub mnuZoomOut_Click()
        If ViewRate <= 0.1 Then
            '·í¤p©ó 1/10 «h°±¤îÁY¤p
            mnuZoomOut.Enabled = False
        Else
            ViewRate = ViewRate - 0.25
            With Image1
                .Width = OPicWidth * ViewRate
                .Height = OPicHeight * ViewRate
            End With
            ResetScrollValue
        End If
        mnuZoomIn.Enabled = True
    End Sub
    Private Sub VScroll1_Change()
        ReSetImagePosition
    End Sub
    Private Sub VScroll1_Scroll()
        ReSetImagePosition
    End Sub
    '±N§¹¾ã¸ô®|¤Á¥hÀɦWªº¦Û­q¨ç¼Æ¡A¥Øªº¬O­«³] CommonDailog ªº InitDir ÄÝ©Ê
    Private Function CutImagePath(ByVal WholeString As String) As String
    Dim I As Integer
        For I = Len(WholeString) To 1 Step -1
            If Mid(WholeString, I, 1) = "\" Then
                CutImagePath = Left(WholeString, I - 1)
                Exit For
            End If
        Next
    End Function

¦^¯Á¤Þ


Àˬd¥Ø¿ý¤¤¯S©wÀɮ׬O§_¦s¦b


¤ô¤û ¼¶¼g©ó¤å³¹

¦U¦ì«e½ú¤j®a¦n¡A¤p§Ì¼g¤F¤@¬qµ{¦¡¨Ó¶}±ÒÀɮסA¦b³o¤§«e·Q¥[¤J¤@¨Çµ{¦¡½X¨ÓÀˬdÀɮ׬O§_½T©w¦s¦b¡AÀ³¸Ó«ç»ò°µ¤ñ¸û¦n©O?

¦Ñ©Çµª¡G

Dim DirReturn As String
Dim DirSend As String
Dim MsgString As String

    DirSend="YourFilePath&Name"
    DirReturn = Dir(DirSend, vbHidden Or vbDirectory Or vbReadOnly Or vbSystem)
   
    If DirReturn="" Then
        MsgString="§ä¨S¦³°Õ"
    Else
        MsgString="§ä¨ì¤F " & DirReturn & " ÀÉ®×"
    End If
   
    MsgBox MsgString

¦^¯Á¤Þ


Collection À³¥ÎÁ|¨Ò


Peter ¼¶¼g©ó¤å³¹

½Ð°Ý¤°»ò¬O¶°¦Xª«¥ó(Collection)¡H­n«ç»ò¨Ï¥Î¡H¤Î¨ä¨Ï¥Î®É¾÷¬°¦ó¡H

¦Ñ©Çµª¡G

  1. ·í§A»Ý­n°}¦C³B²z¡C
  2. ·í§A°}¦Cùتº¸ê®Æ«D¦P½è®É¡C
  3. Count,Item,Add,Remove ªº¤èªk¡A¦Û¤v¬d Help¡C
  4. µ{¦¡Á|¨Ò¡G
    ¦p§A·Q§â Form ¤W¤@­Ó Text1,Label1,Command1 °µ¤@²Õ¡A¤@°_§ïÅܦr«¬³]©w¡A«h¡G
    Option Explicit

    Dim MyCol As Collection

    Private Sub Form_Load()
        Set MyCol = New Collection
       
        MyCol.Add Text1
        MyCol.Add Label1
        MyCol.Add Command1
    End Sub

    Private Sub ¤j¦r«¬()
    Dim I As Integer
        For I = 1 To MyCol.Count
            MyCol.Item(I).FontSize = 18
            MyCol.Item(I).FontBold = True
        Next
    End Sub

    Private Sub ¤p¦r«¬()
    Dim I As Integer
        For I = 1 To MyCol.Count
            MyCol.Item(I).FontSize = 10
            MyCol.Item(I).FontBold = False
        Next
    End Sub

    ª`·N¡GCollection.Item(Index) °ò©³¬° 1 ¦Ó«D VB ¤@¯ë¹w³]ªº 0 ¡C

¦^¯Á¤Þ


®É¶¡¼È°±


¼È®É·Q¤£¨ì ¼¶¼g©ó¤å³¹

½Ð°ÝVB¦p¦ó¼g¤~¯à¹F¨ì®É¶¡¼È°±´X¬íªº¥\¯à¡H

¦Ñ©Çµª¡G

Dim Delay As Date
    Me.MousePointer = 11
   
    Delay = Now
    Do While Second(Now - Delay) < 3
    Loop
    Me.MousePointer = 0

¼È°±¤T¬íÄÁ

¦^¯Á¤Þ


¤@ª«±±¦h¶µ


­Û­Û ¼¶¼g©ó¤å³¹

¦b¨Ï¥Î¼Ò²Õ®É...¦pªG»Ý­n¥Î¨ì form1 ªº±±¨î¶µ...¥²¶·¼g¦¨ form1.XXX ¡A¦³¨S¦³¿ìªk§ï¬Y¨Ç³]©w...¥i¥H¤£¥Î¥[ form1.¡C

¦Ñ©Çµª¡G

  1. ¦b±M®×¤¤¥[¤J Form1,Form2,Moudle1
  2. ±M®×³]¬° Sub Main() ±Ò°Ê
  3. ¦b Module1 ¥[¤J¡G
    Public TextA As TextBox
    Sub Main()
        Set TextA = Form2.Text1
        Form1.Show
    End Sub
  4. ¦b Form2 ¤W©ñ Text1,2
  5. ¦b Form1 ¥[¤J¡G
    Private Sub Command1_Click()
        TextA.Text = "Form2.Text1 Be Change"
        Set TextA=Form2.Text2
        TextA.Text = "Form2.Text2 Be Change"
        Form2.Show
    End Sub

¦^¯Á¤Þ


¦^­º­¶

1