顯示具有 vb6 標籤的文章。 顯示所有文章
顯示具有 vb6 標籤的文章。 顯示所有文章

2014年5月20日 星期二

VB6 Resize Form & Controls For Screen Size

請參考來源
--
參考來源2:Resize controls to fit when a form resizes
 

vb6 自动调整窗体内控件的大小

參考引用來源:自动调整窗体内控件的大小?如果是,那何必使用控件:
--
 '*************************************************************************
'**模 块 名:ModAutoSize
'**说    明:自动调整窗体控件大小及位置
'**创 建 人:嗷嗷叫的老马
'**             http://www.m5home.com/
'**日    期:2003年12月17日
'**备    注: 摘于网络
'**版    本:V1.0
'*************************************************************************
''   在Form_Load里面调用:
''               ControlAutoSize Me,0
''   在Form_Resize里面调用:
''               ControlAutoSize Me,1
''**********************************
'


Option Explicit
 
Private Type cP
  Wp As Single
  Hp As Single
  Tp As Single
  Lp As Single
End Type
Dim Ap() As cP
 
Private Sub Ai(ByRef mForm As Form)
    On Error Resume Next
    Dim I As Integer
    For I = 0 To mForm.Controls.Count - 1
          With Ap(I)
                .Wp = mForm.Controls(I).Width / mForm.Width
                .Hp = mForm.Controls(I).Height / mForm.Height
                .Lp = mForm.Controls(I).Left / mForm.Width
                .Tp = mForm.Controls(I).top / mForm.Height
          End With
    Next I
End Sub
 
Public Function ControlAutoSize(ByRef mForm As Form, ByVal OptIndex As Long)
    Select Case OptIndex
        Case 0
            mForm.Height = mForm.ScaleHeight
            ReDim Ap(0 To mForm.Controls.Count - 1)
            Call Ai(mForm)
        Case Else
            Dim I As Integer
             
            On Error Resume Next
            With mForm
                For I = 0 To .Controls.Count - 1
                    .Controls(I).Move Ap(I).Lp * .ScaleWidth, _
                                     Ap(I).Tp * .ScaleHeight, _
                                     Ap(I).Wp * .ScaleWidth, _
                                     Ap(I).Hp * .ScaleHeight
                Next I
            End With
    End Select
End Function

2014年5月15日 星期四

過濾集數 1-3,8 寫法

以前就遇到租書軟體轉檔集數標示的問題!
----
特殊集數範圍或是多集輸入法:
1.  2-5
2.  33
3.  3-11,12
4.  2-5,6-9
----
這次又遇到此寫法,想了好久;最終還是破解此問題!
 Private Sub Command1_Click()
For i = 0 To 10
   Select Case i
     Case 2 To 5, 7
       Print i
   End Select
Next i
End Sub
-------------
將所有集數倒出來,再利用程式來過濾
當然這樣會有一個問題,就是當集數全展開;筆數會非常龐大
但沒辦法,這種鳥寫法 ; 就得用這種過濾來處理

2014年4月22日 星期二

2014年2月13日 星期四

vb6 由外部往內繞繪線

參考引用來源
--
 Option Explicit

Private Sub Form_Load()
Dim i As Integer, j As Integer, k As Integer
Dim x As Integer, y As Integer
Form1.ScaleMode = 3
Form1.AutoRedraw = True

x = Form1.ScaleWidth \ 2
y = Form1.ScaleHeight \ 2
j = 8
k = 8
For i = 0 To 5
Form1.Line (x, y)-(x - j, y)
x = x - j
j = j + k
Form1.Line (x, y)-(x, y + j)
y = y + j
j = j + k
Form1.Line (x, y)-(x + j, y)
x = x + j
j = j + k
Form1.Line (x, y)-(x, y - j)
y = y - j
j = j + k
Next i
End Sub

2013年6月13日 星期四

VB6 RDS

參考引用:如何: 使用 RDS 從在 Visual Basic 程式中
參考:RDS Code Examples in Visual Basic
--
Dim rs As Object   'Recordset
   Dim ds As Object   'RDS.DataSpace
   Dim df As Object   'RDSServer.DataFactory

   Private Sub Form_Load()
   Set ds = CreateObject("RDS.DataSpace")
   Set df = ds.CreateObject("RDSServer.DataFactory", _
   "http://myserver")
   End Sub

   Private Sub Command1_Click()
   'This query returns a recordset over HTTP.
   Dim strCn As Variant, strSQL As Variant
   strCn = "dsn=pubs;Username=;PWD="
   strSQL = "select * from authors"
   Set rs = df.Query(strCn, strSQL)
   Debug.Print rs(0)     'Print Row 1, Col 1 to Debug window
   End Sub

   Private Sub Command2_Click()
   'This example executes an action query but does not return
   'a recordset.
   Dim strCn As Variant, strSQL As Variant
   strCn = "dsn=pubs;Username=;PWD="
   strSQL = "Update authors Set au_fname = 'Jon' Where au_lname" _
   & " Like 's%'"
   df.Query strCn, strSQL
   End Sub

2013年6月12日 星期三

Get Column Name and Data Types of Access Tables

vb6:Field type reference - names and values for DDL, DAO, and ADOX
參考引用:Get Column Name and Data Types of Access Tables
--
 Private Sub Demo(ByVal ConnectionString As String)
   Using cn As New OleDbConnection(ConnectionString)
      Dim Result = SchemaInfo(cn.ConnectionString, "Table1")
      For Each row As DataRow In Result.Rows
         Console.WriteLine("Name={0} Type={1}", row("ColumnName"), row("DataType"))
      Next
   End Using
End Sub
Public Function SchemaInfo(ByVal ConnectionString As String, ByVal TableName As String) As DataTable
   Dim dt As New DataTable With {.TableName = "Schema"}

   dt.Columns.AddRange( _
      New DataColumn() _
         { _
            New DataColumn("ColumnName", GetType(System.String)), _
            New DataColumn("DataType", GetType(System.String)) _
         } _
      )

   Using cn As New OleDbConnection(ConnectionString)
      Using cmd As New OleDbCommand("SELECT * FROM " & TableName, cn)
         cn.Open()
         Dim Reader As OleDbDataReader = cmd.ExecuteReader(CommandBehavior.KeyInfo)
         Dim schemaTable = Reader.GetSchemaTable()
         schemaTable.TableName = "TableSchema"

         Dim sw As New IO.StringWriter
         schemaTable.WriteXml(sw)
         Dim Doc = New XDocument
         Doc = XDocument.Parse(sw.ToString)
         Dim query = _
            ( _
               From T In Doc... _
               Select _
                  Name = T..Value, _
                  DataType = T..Value.Split(","c)(0).Replace("System.", "") _
            ).ToList

         For Each item In query
            Dim Row As DataRow
            Row = dt.NewRow
            Row("ColumnName") = item.Name
            Row("DataType") = item.DataType
            dt.Rows.Add(Row)
         Next

      End Using
   End Using

   Return dt

End Function
----
上面寫這麼多,套用取 data type

 
OleDbType myDT = (OleDbType)row["DATA_TYPE"];

VBNET:
 Dim myDT As OleDbType = CType(row("DATA_TYPE"), OleDbType)

2013年5月29日 星期三

同時安裝 VB6 和 VS 2012 的問題

同時安裝 VB6 和 VS 2012 後,當開 VB6 卻發生:

真是納悶,怎還會去觸發這些?
查到一篇:Visual Studio 2012 VB6 Installer Error

看來問題是一樣的 ...
---
其實上面這問題,按取消 (Cancel)即可了
但出現這視窗實在是...很悶

2013年5月21日 星期二

vb6 textbox 全選

參考來源
--

Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
這方法必須寫在 GotFocus

2013年3月27日 星期三

DownloadX ActiveX

官網
--
DownloadX ActiveX Download Control is very versatile. It can be used with any programming language including VB.NET, C#, C++, Delphi, ASP, ASP.NET, PHP, and Java. This download tool is able to support all major network protocols including HTTP, FTP/ FTPS, HTTPS, as well as proxy servers, and so all you need to do is specify the file you'd like to download and the process will start right away

2013年3月20日 星期三

證交所&期交所的資料如何捉下來分析

參考引用
--
1. 2008/5月的日線連結路徑如下:
http://www.tse.com.tw/ch/trading/exchange/STOCK_DAY/genpage/Report200805/200805_F3_1_8_1101.php?STK_NO=1101&myear=2008&mmon=05

2. 2008/4月的日線連結路徑如下:
http://www.tse.com.tw/ch/trading/exchange/STOCK_DAY/genpage/Report200804/200804_F3_1_8_1101.php?STK_NO=1101&myear=2008&mmon=04

2013年1月9日 星期三

keybd_event 使用

參考:Keyboard Events Simulation using keybd_event() function
參考引用
--
 Const VK_H = 72
Const VK_E = 69
Const VK_L = 76
Const VK_O = 79
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal _ dwFlags As Long, ByVal dwExtraInfo As Long)

Private Sub Form_KeyPress(KeyAscii As Integer)
'Print the key on the form
Me.Print Chr$(KeyAscii);
End Sub

Private Sub Form_Paint()
'Clear the form
Me.Cls
keybd_event VK_H, 0, 0, 0 ' press H
keybd_event VK_H, 0, KEYEVENTF_KEYUP, 0 ' release H
keybd_event VK_E, 0, 0, 0 ' press E
keybd_event VK_E, 0, KEYEVENTF_KEYUP, 0 ' release E
keybd_event VK_L, 0, 0, 0 ' press L
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0 ' release L
keybd_event VK_L, 0, 0, 0 ' press L
keybd_event VK_L, 0, KEYEVENTF_KEYUP, 0 ' release L
keybd_event VK_O, 0, 0, 0 ' press O
keybd_event VK_O, 0, KEYEVENTF_KEYUP, 0 ' release O
End Sub

 Option Explicit

Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_LSHIFT = &HA0 ' Left SHIFT
Private Const VK_RSHIFT = &HA1 ' Right SHIFT
Private Const VK_LCONTROL = &HA2 ' Left CTRL
Private Const VK_RCONTROL = &HA3 ' Rght CTRL
Private Const VK_a = 65

Private Sub Form_Activate()
    Text1.Text = ""
    Text1.SetFocus

    ' a
    keybd_event VK_a, 0, 0, 0 ' Press 'a'
    keybd_event VK_a, 0, KEYEVENTF_KEYUP, 0 ' Release 'a'
    
    ' A (LEFT SHIFT + 'a')
    keybd_event VK_LSHIFT, 0, 0, 0 ' Press LEFT SHIFT
    keybd_event VK_a, 0, 0, 0 ' Press 'a'
    keybd_event VK_a, 0, KEYEVENTF_KEYUP, 0 ' Release 'a'
    keybd_event VK_LSHIFT, 0, KEYEVENTF_KEYUP, 0 ' Release SHIFT
End Sub
 Symbolic 
constant name Value
(hexadecimal) Keyboard (or mouse) equivalent
VK_LBUTTON 01 Left mouse button
VK_RBUTTON 02 Right mouse button
VK_CANCEL 03 Control-break processing
VK_MBUTTON 04 Middle mouse button (three-button mouse)
VK_BACK 08 BACKSPACE key
VK_TAB 09 TAB key
VK_CLEAR 0C CLEAR key
VK_RETURN 0D ENTER key
VK_SHIFT 10 SHIFT key
VK_CONTROL 11 CTRL key
VK_MENU 12 ALT key
VK_PAUSE 13 PAUSE key
VK_CAPITAL 14 CAPS LOCK key
VK_ESCAPE 1B ESC key
VK_SPACE 20 SPACEBAR
VK_PRIOR 21 PAGE UP key
VK_NEXT 22 PAGE DOWN key
VK_END 23 END key
VK_HOME 24 HOME key
VK_LEFT 25 LEFT ARROW key
VK_UP 26 UP ARROW key
VK_RIGHT 27 RIGHT ARROW key
VK_DOWN 28 DOWN ARROW key
VK_SELECT 29 SELECT key
VK_PRINT 2A PRINT key
VK_EXECUTE 2B EXECUTE key
VK_SNAPSHOT 2C PRINT SCREEN key
VK_INSERT 2D INS key
VK_DELETE 2E DEL key
VK_HELP 2F HELP key
30 0 key
31 1 key
32 2 key
33 3 key
34 4 key
35 5 key
36 6 key
37 7 key
38 8 key
39 9 key
41 A key
42 B key
43 C key
44 D key
45 E key
46 F key
47 G key
48 H key
49 I key
4A J key
4B K key
4C L key
4D M key
4E N key
4F O key
50 P key
51 Q key
52 R key
53 S key
54 T key
55 U key
56 V key
57 W key
58 X key
59 Y key
5A Z key
VK_NUMPAD0 60 Numeric keypad 0 key
VK_NUMPAD1 61 Numeric keypad 1 key
VK_NUMPAD2 62 Numeric keypad 2 key
VK_NUMPAD3 63 Numeric keypad 3 key
VK_NUMPAD4 64 Numeric keypad 4 key
VK_NUMPAD5 65 Numeric keypad 5 key
VK_NUMPAD6 66 Numeric keypad 6 key
VK_NUMPAD7 67 Numeric keypad 7 key
VK_NUMPAD8 68 Numeric keypad 8 key
VK_NUMPAD9 69 Numeric keypad 9 key
VK_SEPARATOR 6C Separator key
VK_SUBTRACT 6D Subtract key
VK_DECIMAL 6E Decimal key
VK_DIVIDE 6F Divide key
VK_F1 70 F1 key
VK_F2 71 F2 key
VK_F3 72 F3 key
VK_F4 73 F4 key
VK_F5 74 F5 key
VK_F6 75 F6 key
VK_F7 76 F7 key
VK_F8 77 F8 key
VK_F9 78 F9 key
VK_F10 79 F10 key
VK_F11 7A F11 key
VK_F12 7B F12 key
VK_F13 7C F13 key
VK_F14 7D F14 key
VK_F15 7E F15 key
VK_F16 7F F16 key
VK_F17 80H F17 key
VK_F18 81H F18 key
VK_F19 82H F19 key
VK_F20 83H F20 key
VK_F21 84H F21 key
VK_F22 85H F22 key
VK_F23 86H F23 key
VK_F24 87H F24 key
VK_NUMLOCK 90 NUM LOCK key
VK_SCROLL 91 SCROLL LOCK key
VK_LSHIFT A0 Left SHIFT key
VK_RSHIFT A1 Right SHIFT key
VK_LCONTROL A2 Left CONTROL key
VK_RCONTROL A3 Right CONTROL key
VK_LMENU A4 Left MENU key
VK_RMENU A5 Right MENU key
VK_PLAY FA Play key
VK_ZOOM FB Zoom key

Visual Basic Windows API Function

Ex-designz.net is a friendly,fun,entertaining,interactive,informational Web portal and global community.

Visual Basic Windows API Function

For Each Split 運用


Private Sub Command1_Click()
Dim add_count As Integer
Dim a As String
a = "11,22,33"
add_count = 0
Dim b As Variant
For Each b In Split(a, ",")
    Print b
    add_count = add_count + 1
Next
Print add_count

End Sub
--
基本運用,靠自己發揮了~

2013年1月5日 星期六

vb6 網域轉IP

參考1
引用來源
--
  Private Sub Form_Load()
    MsgBox DomainNameToIP("wushi.myftp.org")
End Sub


Option Explicit
 
Private Type HOSTENT
    hName As Long
    hAliases As Long
    hAddrType As Integer
    hLength As Integer
    hAddrList As Long
End Type
 
Private Type WSADATA
    wversion As Integer
    wHighVersion As Integer
    szDescription(0 To 256) As Byte
    szSystemStatus(0 To 128) As Byte
    iMaxSockets As Integer
    iMaxUdpDg As Integer
    lpszVendorInfo As Long
End Type
 
Private Declare Function WSAGetLastError Lib "WSOCK32.DLL" () As Long
Private Declare Function WSAStartup Lib "WSOCK32.DLL" (ByVal wVersionRequired As Integer, lpWSAData As WSADATA) As Long
Private Declare Function WSACleanup Lib "WSOCK32.DLL" () As Long
Private Declare Function gethostname Lib "WSOCK32.DLL" (ByVal szHostname As String, ByVal HostLen As Long) As Long
Private Declare Function gethostbyname Lib "WSOCK32.DLL" (ByVal szHostname As String) As Long
Private Declare Sub RtlMoveMemory Lib "KERNEL32" (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
 
Private Const WS_VERSION_REQD = &H101
 
Public Function DomainNameToIP(URL As String) As String
    InitializeWinSock
    DomainNameToIP = GetAddressByName(URL)
    TerminateWinSock
End Function
 
Private Function GetAddressByName(strHostname As String)
    Dim lngAddr As Long
    Dim udtHost As HOSTENT
    Dim lngIP As Long
    Dim bteTmp() As Byte
    Dim i As Integer
    Dim strIP As String
 
    lngAddr = gethostbyname(strHostname)
 
    If lngAddr = 0 Then
        MsgBox "Kein Host gefunden."
        GetAddressByName = Null
        Exit Function
    End If
 
    RtlMoveMemory udtHost, lngAddr, LenB(udtHost)
    RtlMoveMemory lngIP, udtHost.hAddrList, 4
 
    ReDim bteTmp(1 To udtHost.hLength)
    RtlMoveMemory bteTmp(1), lngIP, udtHost.hLength
    For i = 1 To udtHost.hLength
        strIP = strIP & bteTmp(i) & "."
    Next
    strIP = Mid$(strIP, 1, Len(strIP) - 1)
 
    GetAddressByName = strIP
End Function
 
Private Sub InitializeWinSock()
    Dim udtWSAD As WSADATA
    Dim lngRet As Long
    lngRet = WSAStartup(WS_VERSION_REQD, udtWSAD)
    If lngRet <> 0 Then
        MsgBox "Winsock.dll konnte nicht initialisiert werden."
        End
    End If
End Sub
 
Private Sub TerminateWinSock()
    Dim lngRet As Long
    lngRet = WSACleanup()
    If lngRet <> 0 Then
        MsgBox "Fehler " & lngRet & " beim Beenden von Winsock.dll"
        End
    End If
End Sub