www.pudn.com > kelon.rar > Module1.bas


Attribute VB_Name = "mod01" 
Option Explicit 
 
Public Declare Function GetPrivateProfileString& Lib "kernel32" Alias "GetPrivateProfileStringA" ( _ 
        ByVal lpApplicationName As String, ByVal lpKeyName As String, _ 
        ByVal lpDefault As String, ByVal lpReturnedString As String, _ 
        ByVal nSize As Long, ByVal lpFileName As String) 
Public Declare Function WritePrivateProfileString& Lib "kernel32" Alias "WritePrivateProfileStringA" ( _ 
        ByVal lpApplicationName As String, _ 
        ByVal lpKeyName As String, _ 
        ByVal lpString As Any, _ 
        ByVal lpFileName As String) 
         
Public frmColor(3) As Long 
Public Sub pubGetColor(ByVal Index As Long) 
    Dim ls As String, key As String 
'    key = "color" + Format(Index, "00") 
    ls = pGetString(iniFn, "local", "color" + Format(Index, "00")) 
    Dim arry As Variant 
    arry = Split(ls, ",") 
    If UBound(arry) > 2 Then 
        frmColor(0) = arry(0):        frmColor(1) = arry(1) 
        frmColor(2) = arry(2):        frmColor(3) = arry(3) 
    End If 
End Sub 
'取字符串的通用程序 
Public Function pGetString(ByVal sfn As String, ByVal ssec As String, ByVal skey As String) As String 
    pGetString = "" 
    Dim ss As String * 255 
    Dim ls As String 
    Dim l As Long 
    ss = "" 
    l = GetPrivateProfileString(ssec, skey, "", ss, 250, sfn) 
    If l = 0 Then GoTo end_fun 
    pGetString = Trim(Left(ss, l)) 
end_fun: 
End Function 
Public Function vbStr(ByVal ss As String) As String 
    Dim nStr As String 
    Dim P As Long 
    Dim i As Long 
    Dim IsZero As String 
    vbStr = "" 
    nStr = ss 
    If ss = "" Then Exit Function 
    P = InStr(1, ss, Chr(0)) 
    If P > 0 Then nStr = Left(ss, P - 1) 
    vbStr = Trim(nStr)    '去空字串 
End Function 
Public Sub SaveWindowSize(ByVal frm As Form, ByVal Index As Long) 
    Dim ls As String, key As String 
    key = "windows" + Format(Index, "00") 
    ls = frm.Left & "," & frm.Top & "," & frm.Width & "," & frm.Height 
    Call WritePrivateProfileString("local", key, ls, iniFn) 
End Sub 
Public Sub SetWindowSize(ByVal frm As Form, ByVal Index As Long) 
'    Call priGetColor(Index) '取得颜色 
    Dim ls As String, key As String 
'    key = "windows" + Format(Index, "00") 
    ls = pGetString(iniFn, "local", "windows" + Format(Index, "00")) 
    Dim arry As Variant 
    arry = Split(ls, ",") 
    If UBound(arry) > 2 Then 
        frm.Move Val(arry(0)), Val(arry(1)), Val(arry(2)), Val(arry(3)) 
    End If 
End Sub