

                         VBForums -    ̳ 


                         .       
               


      VBForums-̳: HTTP://vbforums.yeah.net
         
               ύʼ: VBForums@usa.net?Subject=VBForums

         нϵ: ympang@bigfoot.com?subject=VBForumsĽ


:
    ڻشʱ, A???? ʽΪ,ʺŴ.
    ýⲿԡ>  :ȷƽڻشʼǰ
    һУǩĴ
                                - VBForums

Q0110:
    foxproо&滻, REPL  ALL &ZD WITH &GS FOR  &TJ, 
    ZDΪ洢ֶı,GSΪ洢滻ʽı, 
    TJΪ洢ı.ʸλ,VB5.0ܷʵֲ!
                                - ѩ.

?
Q0111:
    ҵӦóõExcelMyAppΪEXcel.Application,
    MyBookΪExcel.WorkBook,MySheetΪExcel.WorksheetӡԤMySheet,
    ԤرպصҵӦóУǻصExcelУô???
                                - Zhi Chen
?
Q0112:
    ͬ־!
    ҵһС,VB5һЩµĻؼ:Maskedbox,ڻûܶ
    ϸһ,ܷ˵ĸָһС,ϸһ,
    Щѧϰһ,ͬ.
                                - лл!

߰:
    Ҳһ뷨,λ.
                                - Pang in VBForums

?
Q0113:
    :access97ݿⱻVBǰƽ̨?
                                - huangtk

?
?
Ϣ:
    All boys here, would you like to know about VB6, please have a look
as follow:

__Microsoft To Introduce Visual Basic Upgrade__

Microsoft next week will unveil an upgrade to Visual Basic, adding
features for easier data access and simpler application deployment. The
company says the tool's latest incarnation is designed to help
developers build scalable enterprise applications. Added features will
include the integration of Visual Database Tools and a Data
Environment Designer component to facilitate the design of
Oracle and SQL Server databases, and data access queries.

Visual Basic 6.0 will also come with greater support for ActiveX Data
Objects, which will make it easier for developers to access data from
messaging servers and in-house databases. Other extended features
include RAD Web development, which programmers can use to build
browser-independent Web applications, and Dynamic HTML pages. The
upgrade will also include a WebClass Designer component that
will offer object models to simplify the development of Web
applications. "With 6.0, we wanted to make improvements to help VB
developers be a lot more productive," says Carolyn  Duffy, lead
marketing manager for Visual Basic.  The upgrade is expected to ship in
September.

        Regards
                -----Lu Jun

A0109
  >> ֪ϵͳЩⲿ̡Zipȣβ
  >> Ƿ̣̣εWin95˵Сһ

  About Question 1:

    using GetDriveType to detect, below is the example for  detecting
    CD-ROM, others I am not try, you may look up the detail of the funtion,
    you can fix it.

    'Private Declare Function GetDriveType Lib "kernel32" Alias
    "GetDriveTypeA" (ByVal nDrive As String) As Long
    'Private Declare Function GetLogicalDriveStrings Lib "kernel32" Alias
    "GetLogicalDriveStringsA" (ByVal nBufferLength As Long, ByVal lpBuffer
    As String) As Long
    'Private Const DRIVE_REMOVABLE = 2
    'Private Const DRIVE_FIXED = 3
    'Private Const DRIVE_REMOTE = 4
    'Private Const DRIVE_CDROM = 5
    'Private Const DRIVE_RAMDISK = 6


    'Place the following code in under a command button or in a menu, etc...

    Dim r&, allDrives$, JustOneDrive$, pos%, DriveType&
    Dim CDfound As Integer
    allDrives$ = Space$(64)
    r& = GetLogicalDriveStrings(Len(allDrives$), allDrives$)
    allDrives$ = Left$(allDrives$, r&)
    Do
    pos% = InStr(allDrives$, Chr$(0))
    If pos% Then
        JustOneDrive$ = Left$(allDrives$, pos%)
        allDrives$ = Mid$(allDrives$, pos% + 1, Len(allDrives$))
        DriveType& = GetDriveType(JustOneDrive$)
        If DriveType& = DRIVE_CDROM Then
           CDfound% = True
           Exit Do
        End If
    End If
    Loop Until allDrives$ = "" Or DriveType& = DRIVE_CDROM
    If CDfound% Then
        label1 = "The CD-ROM drive on your system is drive " &
    UCase$(JustOneDrive$)
      Else: label1 = "No CD-ROM drives were detected on your system."
    End If

About question 2:
    below is example for how to open & close CD-ROM drive.

    'Private Declare Function mciSendString Lib "winmm.dll" Alias_
    "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString
    As String, _
    ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long


    'Open CD drive door
    retvalue = mciSendString("set CDAudio door open", returnstring, 127, 0)

    'Close CD drive door
    retvalue = mciSendString("set CDAudio door closed", returnstring, 127,0)


                    Regards
                ----- Lu Jun
                Mailto:lujun-8@bigfoot.com





==========================================================================
ѡ


         д ֱ  ʹ ODBC API  ODBC    VB   



----       ODBC    ΪClient Server  
 Ӧ  ϵ ͳ    Զ      һ   ׼  Ϊ ǿ 
 ǰ     ߣMS Visual Basic Ϊ         
ODBC   Դ  ;  JET     桢ODBC API  RDO
  ȡ    ԣ ֱ  ʹ ODBC API        
        ȡ       Ҳ   ѡ  Ȼ
VB 4.0  ҵ    RDO         ODBC API 
    ǣ     ֻ  32 λWindows     У
ODBC API    û     ơ 

ODBC API        

----  ʹ     ̬    һ  VB  ʹ ODBC API 
 ֮ ǰ        Ҫ ʹ         
 ODBC API   פ  ODBC    ̬ ODBC.DLL16 λ
ODBC32.DLL32 λ У   ̬  λ Windows  Ŀ ¼system
С ͨ     VB  Ŀ    ʹ  һ  ģ    Ȼ
 ODBC API        У    ʾ     ʵ
  ʹ   ģ   module1.bas   ݣ 

---- Declare Function SQLAllocEnv Lib "odbc32.dll" (phenv&) As
Integer 
---- Declare Function SQLAllocConnect Lib "odbc32.dll" (ByVal henv&,
phdbc&) As Integer 
---- Declare Function SQLAllocStmt Lib "odbc32.dll" (ByVal hdbc&,
phstmt&) As Integer 
---- Declare Function SQLConnect Lib "odbc32.dll" (ByVal hdbc&,
ByVal szDSN$, ByVal cbDSN%, ByVal szUID$, ByVal cbUID%, ByVal
szAuthStr$, ByVal cbAuthStr%) As Integer 
---- Declare Function SQLColAttributesString Lib "odbc32.dll" Alias
"SQLColAttributes" (ByVal hstmt&, ByVal icol%, ByVal fDescType%,
ByVal rgbDesc As String, ByVal cbDescMax%, pcbDesc%, pfDesc&) As
Integer 
---- Declare Function SQLDisconnect Lib "odbc32.dll" (ByVal hdbc&)
As Integer 
---- Declare Function SQLExecDirect Lib "odbc32.dll" (ByVal hstmt&,
ByVal szSqlStr$, ByVal cbSqlStr&) As Integer 
---- Declare Function SQLFetch Lib "odbc32.dll" (ByVal hstmt&) As
Integer 
---- Declare Function SQLFreeConnect Lib "odbc32.dll" (ByVal hdbc&)
As Integer 
---- Declare Function SQLFreeEnv Lib "odbc32.dll" (ByVal henv&) As
Integer 
---- Declare Function SQLFreeStmt Lib "odbc32.dll" (ByVal hstmt&,
ByVal fOption%) As Integer Declare Function SQLGetData Lib
"odbc32.dll" (ByVal hstmt&, ByVal icol%, ByVal fCType%, ByVal
rgbValue As String, ByVal cbValueMax&, pcbValue&) As Integer 
---- Declare Function SQLNumResultCols Lib "odbc32.dll" (ByVal
hstmt&, pccol%) As Integer 
---- Global Const SQL_C_CHAR As Long = 1 
---- Global Const SQL_COLUMN_LABEL As Long = 18 
---- Global Const SQL_DROP As Long = 1 
---- Global Const SQL_ERROR As Long = -1 
---- Global Const SQL_NO_DATA_FOUND As Long = 100 
---- Global Const SQL_SUCCESS As Long = 0 

----  Ҫ ˵   ǣ      ʱ Ӧ       
   ѡ   Ӧ   ̬ ⡣ VB  Ŀ
¼samples\remauto\db_odbc        ODBC16.TXT
ODBC32.TXT      16 λ 32 λODBC API    
         䣬   ʱ         
   䡣 

ʹ ODBC API      

---- VB   ODBC API    ODBC   ⣬     һ
          ģ 

һ  ʼ ODBC 

----      У Ӧ     ͨ   SQLAlloEnv  
 ʼ ODBC  ڣ  ȡODBC    ODBC      
  ODBC  Դ                
 ODBC  ӣ     ֻ  ִ  һ   ɡ  磺 

---- Dim rc As Integer 'ODBC       
---- Dim henv As Long 'ODBC     
---- rc = SQLAllocEnv(henv) '  ȡODBC     

 ODBC   Դ     

----             ɣ 

---- 1  SQLAllocConnect    ȡ      磺 
---- Dim hdbc As Long '     
---- rc = SQLAllocConnect(henv, hdbc) '  ȡ     

---- 2    ӡ       ͨ      ʵ ֣
   ֱ       SQLConnect    磺 
---- Dim DSN As String, UID As String, PWD As String 
---- DSN = "DataSourceName" 'ODBC   Դ   
---- UID = "UserID" '     
---- PWD = "Password" '     
---- rc = SQLConnect(hdbc, DSN, Len(DSN), UID, Len(UID), PWD,
Len(PWD)) '     

  ȡ   

----   ODBC   Դ   ȡ     ͨ SQL   ʵ
 ġ      У Ӧ     ͨ    ODBC  
  SQL  䣬               
£ 

---- 1  SQLAllocStmt    ȡ      磺 
---- Dim hstmt As Long 
---- rc = SQLAllocStmt(hdbc, hstmt) 

---- 2 ִ SQL  䡣 ִ SQL        ࣬  
        SQLAllocStmt    磺 
---- Dim SQLstmt As String 
---- SQLstmt = "SELECT * FROM authors" 
---- rc = SQLExecDirect(hstmt, SQLstmt, Len(SQLstmt)) 

ġ      

----  SQL    ˳      ȷ ִ У  ô   
 һ               ࣬    
ֱ       SQLFetch SQLGetData  SQLFetch  
          ǰ  ¼ ָ     һ   ¼
SQLGetData        ȡ      ǰ  ¼  ĳ 
  ֵ ͨ      һ  ѭ    ȡ      
 ¼      ֵ  ѭ    ִ SQLFetch SQLGetData
  ֱ SQLFetch    SQL_NO_DATA_FOUND   ʾ  
      ĩ β 

---- Dim ColVal As String * 225 
---- ColVal = String(255, 0) 
---- Do Until SQLFetch(hstmt) = SQL_NO_DATA_FOUND 
---- rc = SQLGetData(hstmt, i, SQL_C_CHAR, ColVal, Len(ColVal),
SQL_NULL_DATA) 
---- Loop 

塢   Ӧ    

----  Ӧ               ֮ ǰ  
     ʹ   ϵ ͳ  Դ  Щ ϵ ͳ  Դ   
       ODBC            
  £ 

---- 1  SQLFreeStmt              ϵ
ͳ  Դ  磺 
---- rc = SQLFreeStmt(hstmt, SQL_DROP) 

---- 2  SQLDisconnect      ӡ  磺 
---- rc = SQLDisconnect(hdbc) 

---- 3  SQLFreeConnect             
ϵ ͳ  Դ  磺 
---- rc = SQLFreeConnect(hdbc) 

---- 4  SQLFreeEnv              ϵ
ͳ  Դ ͣ ֹODBC    磺 
---- rc = SQLFreeEnv(henv) 

----  ⣬      ʱ   һ   Ҫ      
⣬         ODBC API     ִ   
        һ   ׼    SQL_ERROR һ 
   ÿ   ODBC API   ֮   Ӧ      
  ֵ ȷ          ִ У      
    ̡   ϸ     Ϣ    SQLError  
 áSQLError         Ϣ 

      ׼ ODBC   ״ ̬  
     ODBC   Դ          
        Ϣ  

  Ӧ  ʵ  

----  ʵ     һ     VB Ӧ    ͨ 
Windows NT     ѯ    MS SQL Server 6.5    
PUBS  AUTHORS      һ Grid     ʾ  ѯ
   ȣ ʹ Windows      ODBC      
 һ ODBC   Դ     Դ   ΪODBC_API_DEMO  
 ¼    ΪPUBS    Ϣ Ӧ         ȷ 
á Ȼ   VB   һ   ĿProject1  ȱ ʡ  
Form1    һ Grid  Grid1  CommandButton 
cmdQuery cmdClose Project1    һ  ģ Module1 
ǰ            С      £ 

Private Sub Form_Load()
Dim rc As Integer
  rc = SQLAllocEnv(henv)
  If rc <> 0 Then
    MsgBox "    ʼ ODBC"
    End
  End If
  rc = SQLAllocConnect(henv, hdbc)
  If rc <> 0 Then
    MsgBox "        "
    rc = SQLFreeEnv(henv)
    End
  End If
Dim DSN As String, UID As String, PWD As String
  DSN = "ODBC_API_DEMO"
  UID = "guest"
  PWD = ""
  rc = SQLConnect(hdbc, DSN, Len(DSN), UID, Len(UID), PWD, Len(UID))
  If rc = SQL_ERROR Then
    MsgBox "     ODBC   Դ   "
    End
  End If
End Sub
Private Sub cmdQuery_Click()
Dim hstmt As Long
Dim SQLstmt As String
Dim RSCols As Integer, RSRows As Long
Dim rc As Integer, i As Integer, j As Integer
Dim ColVal As String * 1024
Dim ColValLen As Long, ColLabLen As Integer, larg As Long
  rc = SQLAllocStmt(hdbc, hstmt)
  If rc <> SQL_SUCCESS Then
    MsgBox "    SQL    "
    Exit Sub
  End If
  SQLstmt = "SELECT * FROM authors"
  rc = SQLExecDirect(hstmt, SQLstmt, Len(SQLstmt))
  If rc <> SQL_SUCCESS Then
    MsgBox "SQL   ִ  ʧ "
    Exit Sub
  End If
  rc = SQLNumResultCols(hstmt, RSCols)
  If RSCols > 1 Then
    Grid1.Cols = RSCols
    Grid1.Rows = 10
    Grid1.Row = 0
  Else
    Exit Sub
  End If
  For i = 1 To RSCols
rc = SQLColAttributesString(hstmt, i, SQL_COLUMN_LABEL,
    ColVal, 255, ColLabLen, larg)
    Grid1.Col = i - 1
    Grid1.Text = Left(ColVal, ColLabLen)
  Next i
  Do Until SQLFetch(hstmt) = SQL_NO_DATA_FOUND
    ColVal = String$(1024, 0)
    If Grid1.Row + 1 >= Grid1.Rows Then
      Grid1.Rows = Grid1.Rows + 1
    End If
    Grid1.Row = Grid1.Row + 1
    For i = 1 To RSCols
      rc = SQLGetData(hstmt, i, SQL_C_CHAR, ColVal,
          Len(ColVal), ColValLen)
      Grid1.Col = i - 1
      Grid1.Text = Left$(ColVal, ColValLen)
    Next i
  Loop
  rc = SQLFreeStmt(hstmt, SQL_DROP)
End Sub
Private Sub cmdClose_Click()
Dim rc As Integer
  If hdbc <> 0 Then
    rc = SQLDisconnect(hdbc)
  End If
  rc = SQLFreeConnect(hdbc)
  If henv <> 0 Then
    rc = SQLFreeEnv(henv)
  End If
  End
End Sub

---- ʵʹVisual Basic 4.0 Windows 95 ¿ġ 
==========================================================================
˶ http://server.com/WebApps/mail-list-unsubscribe.cgi?id=4093


