Visual Basic 6 & Access 2000


Closed Thread
Results 1 to 34 of 34
  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596

    Default Visual Basic 6 & Access 2000

    Hi,

    This thread is meant as a meeting place for discussion about VB6 and Access in PIC/USB-related projects.

    Keith, this tutorial explains database access much better than the Step By Step or Programmer's Guide books from Microsoft that came with my VB6 package.

    http://www.vbexplorer.com/VBExplorer...er_ADO_DAO.asp

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  2. #2
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    A better title for this thread would be:

    Visul Basic 6.0 & ADO/Jet database engine

    Best regards,

    Luciano

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    Not really 'cause I'm using Access to store the data. I'll have tons of questions on that too so I thought this would be a nice place to put them.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  4. #4
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default Stored Queries

    One cool thing I've done in the past is utilized stored queries to minimize code. These are similar to stored procedures if you utilize Oracle. You basically create a common sql statement in access, then call that in your vb app (ASP in my case) with the parameters required for the stored query. Here's an example of what I've done.... keep in mind it is for an ASP webpage, but should be similar for VB.

    Code:
    *****************************************************
    <%
    	' -- InsertProc.asp --
    %>
    <html>
    <head>
    	<title>Running Stored Procedures in Access Database (Insert Value)</title>
        <style>p { font-family:verdana,arial; font-size:10pt; font-weight:bold; }</style>
    </head>
    <body><p>
    <%	
    	' Connection String
    	Dim connStr
    		connStr = "DRIVER=Microsoft Access Driver (*.mdb);DBQ="
    		connStr = connStr & Server.MapPath("StoredProc.mdb") & ";PWD=Whateveryourpasswordis"
    
    		
    	' Connection Object
    	Dim con
    		Set con = Server.CreateObject("ADODB.Connection")
    		
    	' Recordset Object
    	Dim rs
    		
    		' connecting to database
    		con.Open connStr
    Here we execute the insertproc query
    		' executing stored procedure
    		Set rs = con.Execute ("exec InsertProc XXX") ' XXX is the data passed to the stored query
    Now run another stored query called SelectProc               		
    		Set rs = con.Execute ("exec SelectProc")
    		
    		' showing all records %>
    The code below just writes the table data to the web page
    		<table border="1" width="25%">
    		<%for each x in rs.Fields ' Write the field names in the table headers
    			response.write("<th>" & x.name & "</th>")
    		next%>
    		</tr>
    
    		<%do until rs.EOF ' Read thru each record %>
        		<tr>
    
        		<%for each x in rs.Fields ' Put the value of each field of the current record into the table 
           			Response.Write "<td>" & (x.value) & "</td>"
        		next
    
        		rs.MoveNext ' Move to the next record %>
        		</tr>
    		<%loop
    		' Close connections and release the objects in memory	
    		con.Close
    		Set rs = Nothing
    		Set con = Nothing
    
    
    %>
    </p></body>
    </html>
    *************************************************
    The access query is named InsertProc. And the query code looks like this....
    Code:
    INSERT INTO [Names] ( Name )
    VALUES ([@newName]);
    This simple query inserts the value you pass into Table Names into Field Name.
    The code for the SelectProc is this....
    Code:
    SELECT *
    FROM [Names];
    Anyway.... Thought this could be handy for others.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    Here's an example of emptying a database and adding one record:

    Dim dbMenu As Database
    Dim rsMenu As Recordset

    Set dbMenu = OpenDatabase("E:\EasyHID\Xk1 v2\USBProject\VisualBASIC\Modified code\NR2003.mdb")
    Set rsMenu = dbMenu.OpenRecordset("SELECT * FROM tblMenu")

    If Not rsMenu.EOF Then
    rsMenu.Delete
    End If

    rsMenu.AddNew
    rsMenu!ptrMenu = 1
    rsMenu!RecordType = "1"
    rsMenu.Update

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  6. #6
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Exclamation

    Hi Robert,

    First you will have to decide which technology to use
    to access the Microsoft Jet database engine.

    The two options you have with VB 6.0 are:

    Microsoft Data Access Objects (DAO)
    Microsoft ActiveX Data Objects (ADO)

    Once decided, stick with one!

    My two cents advice is to use ADO.

    * * *

    Are you sure that the users of this forum
    are really interested in this stuff?

    There are hundred of forums and tutorials talking
    about VB, so why not search and subscribe there?

    Best regards,

    Luciano

  7. #7
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Luciano
    Are you sure that the users of this forum
    are really interested in this stuff?

    There are hundred of forums and tutorials talking
    about VB, so why not search and subscribe there?
    Isn't that why it's posted in the OFF TOPIC forum?
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  8. #8
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    Search: Key Word(s): vb

    Showing results 1 to 25 of 134


    I think that explains why this thread is justified.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  9. #9
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    There is many Programming forum like the nice www.experts-exchange.com/ but they're not really hardware oriented... well those i know so far.

    http://www.programmersheaven.com/ is another great source.

    Or 1 Million in my bank account will be 'tha solution' LMAO!
    Last edited by mister_e; - 25th August 2006 at 03:36.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  10. #10
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    What techniue would you use to store a "cookie" in VB? I set a drive, folder and filename in a form and I'd like to save that value between sessions.

    Is there a nice and efficient way of doing this besides writing to a text file? Is there a standard way of doing this? I'd prefer a technique where the user could not get his grubby hands into the file and screw up pointers.

    Robert
    Attached Images Attached Images  
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  11. #11
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e
    There is many Programming forum like the nice www.experts-exchange.com/ but they're not really hardware oriented... well those i know so far.

    ...
    The thing is that several of us are going to go through the same steps. It would be a waste of resources to let people have to sprawl all over when all we need are a few good tutorial links and some help on a few questions.

    I'm sure there are tons of good places for GSM, GPS and Bluetooth information. What's the difference? This is just another application that will use PIC and PBP. And when you think about it, Windows is EVERYWHERE today, a lot more than the 3 other applications.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  12. #12
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Lightbulb What about INI files?

    Quote Originally Posted by Demon
    What techniue would you use to store a "cookie" in VB? I set a drive, folder and filename in a form and I'd like to save that value between sessions.
    I use INI files... that's mainly what they're for. Here's a module I use for them. Just add it to your project and use WriteProfileString & FetchProfileString functions to write and read to the INI file.
    Code:
    'ModINIFunctions.bas
    Option Explicit
    
    Private msWinPath As String
    Private mlRetLength As Long
    Private msDirReturn As String
    Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
    Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
    Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
    
    
    Public Function FetchProfileString(ByVal sINIFile As String, ByVal sApp As String, _
                                       ByVal sKey As String, Optional DefVal As Variant) As String
    'Purpose: Reads information from a *.INI file
    
    'Inputs:    sINIFile    String      Name of file INI file including path
    '           sApp        String      Name of application section in INI file
    '                                   Example [My App]
    '           sKey        String      key name under application section
    '           DefValue    String      default value of key
    '
    '           Example   [MyApp]
    '                     MyKey = MyValue
    
    'Assumptions:
    '           1.  Windows API GetPrivateProfileString function declared with the following statement in the
    '               Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA"
    '                   (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
    '
    
    'Effect:   None
        
        Dim sReturn As String
        Dim sDefVal As String
        Dim mlReturnLength As Integer
        
        
        If IsMissing(DefVal) Then
            sDefVal = ""
        Else
            sDefVal = CStr(DefVal)
        End If
    
      '  msDirReturn = Dir(sINIFile)
        
      '  If msDirReturn = "" Then
      '      mlRetLength = WritePrivateProfileString(sApp, sKey, sDefVal, sINIFile)
      '  End If
        
        sReturn = String$(255, 0)
        mlRetLength = GetPrivateProfileString(sApp, sKey, sDefVal, sReturn, 255, sINIFile)
        FetchProfileString = Left$(sReturn, mlRetLength)
        
    End Function
    
    Public Function WriteProfileString(ByVal sINIFile As String, ByVal sApp As String, _
                                       ByVal sKey As String, ByVal sVal As String) As Boolean
        
    'Purpose: stores information to a *.INI file
    
    'Inputs:    sINIFile    String      Name of file INI file including path
    '           sApp        String      Name of application section in INI fil
    '                                   Example [My App]
    '           sKey        String      key name under application section
    '           sValue      String      value of key
    '
    '           Example   [MyApp]
    '                     MyKey = MyValue
    
    'Assumptions:
    '           1.  Windows API WritePrivateProfileString function declared with the following statement in the
    '               Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA"
    '                (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
    '           2. if *.INI file does not exist this function will create the file
    
    'Effect:   Contents of *.INI file
    
    Dim sReturn As String
        
        mlRetLength = WritePrivateProfileString(sApp, sKey, sVal, sINIFile)
        
    End Function
    Here's an example of reading in the language value under the Section named SAP in the Pack.ini file.
    Code:
       PstrLang = FetchProfileString(App.Path & "/PACK.INI", "SAP", "LANGUAGE", "EN")
    Here's an example of how the data in the INI file would look.
    Code:
    ;comments use the semicolon
    ;In this example parameter sApp =  SAP
    ;parameter sKey = Language (there can be multiple keys under one app parameter)
    ;The value returned to PstrLang in the example above is EN
    [SAP]
    LANGUAGE=EN
    This is a really useful way of storing different user preferences etc.
    Another method would be writing and reading to the registry. But I'll let you explore that option.
    Last edited by Demon; - 4th October 2016 at 16:55.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  13. #13
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    Thanks, that looks great.

    I'm not too keen on writing to the registry.

    Robert


    EDIT: Are you sure about this statement?

    -----------------------------------------------------
    Here's an example of reading in the language value under the Section named SAP in the Pack.ini file.

    Code:

    PstrLang = FetchProfileString(App.Path & "/PACK.INI", "SAP", "LANGUAGE", "EN")
    -----------------------------------------------------

    Why read the INI file to find sValue if you are providing it in the statement? This would look more like a Write statement no?
    Last edited by Demon; - 25th August 2006 at 15:59.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  14. #14
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    This one is really off-topic.

    I'd like to copy an Access MDB file from within VB6. I don't even know where to start looking for this. I figure this could be some sort of batch file like we used to be able to do in DOS.

    Robert



    EDIT: Hmmm: http://builder.com.com/5100-6373-1050078.html CopyFile feature, interesting.
    Last edited by Demon; - 27th August 2006 at 16:26.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  15. #15
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    I found this:

    FileSystemObject.CopyFile "c:\mydocuments\letters\*.doc", "c:\tempfolder\"

    But I'm stuck on how to define that FileSystemObject.

    Robert


    EDIT: Found it, I needed to add a Reference to Microsoft Scripting Runtime (scrrun.dll).
    Last edited by Demon; - 27th August 2006 at 17:19.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  16. #16
    Join Date
    Mar 2005
    Location
    Iowa, USA
    Posts
    216


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Demon
    Why read the INI file to find sValue if you are providing it in the statement? This would look more like a Write statement no?
    Look at the FetchProfileString function. You have to provide a default value in this call, then it gets overwritten with what's in the INI file.
    Last edited by Demon; - 4th October 2016 at 16:55.
    Wisdom is knowing what path to take next... Integrity is taking it.
    Ryan Miller

  17. #17
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default Select Where

    How do we point to a VB6 public variable from within a SELECT statement?

    Set rsProfile = dbProfile.OpenRecordset("SELECT * FROM tblProfile WHERE ptrMenu = ptrCurrentMenu")

    Both ptrMenu (primary key) and ptrCurrentMenu are defined as LONG, but it only works when I hardcode a 1 instead of ptrCurrentMenu.

    Robert


    EDIT: Found it in Programmer's Heaven, thanks Steve: ("SELECT * FROM tblProfile WHERE ptrMenu = " & ptrCurrentMenu)
    Last edited by Demon; - 29th August 2006 at 22:51.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  18. #18
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default Null not a null

    I would have expected this IF statement to trap a Null, but apparently it doesn't work that way. The execution fell right down to the ELSE and executes the next statement. Any idea how to do make it work?

    Robert
    Attached Images Attached Images  
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  19. #19
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Demon
    I would have expected this IF statement to trap a Null, but apparently it doesn't work that way. The execution fell right down to the ELSE and executes the next statement. Any idea how to do make it work?

    Robert
    Try "vbNull" instead. (Cant test as I dont have VB on this machine!)
    Last edited by Demon; - 4th October 2016 at 16:56.
    Keith

    www.diyha.co.uk
    www.kat5.tv

  20. #20
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Use the Visual Basic function IsNull().

    Best regards,

    Luciano

  21. #21
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    Thank you!

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  22. #22
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default Reading value of Autonum key after insert

    -----------------------------------------------------
    Dim ptrProfile as Long

    Dim dbProfile As Database
    Set dbProfile = OpenDatabase(strPath & "\" & strFilename)
    Dim rsProfile As Recordset
    Set rsProfile = dbProfile.OpenRecordset("tblProfile")

    rsProfile.AddNew
    rsProfile!Description = "bla bla bla"
    rsProfile.Update

    ptrProfile = rsProfile!ptrMenu <-- Primary key, Autonum
    -----------------------------------------------------

    According to one of my Access books this should place the new key into ptrProfile but it doesn't.

    Am I supposed to set special parameters for update? Like UpdateNow or something like that? I see references to Cursor Types and Record Locks but I can't figure how to use them.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  23. #23
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Try that.

    Best regards,

    Luciano

    Code:
    rsProfile.AddNew
    rsProfile!Description = "bla bla bla"
    ptrProfile = rsProfile!ptrMenu 
    rsProfile.Update
    Last edited by Luciano; - 31st August 2006 at 20:02.

  24. #24
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    Thanks.

    I got the SendKeys sample from the Help file working nicely:

    AppActivate Shell("calc.exe", 1)
    For I = 1 To 100
    SendKeys I & "{+}", True
    Next I
    SendKeys "=", True
    SendKeys "%{F4}", True

    How could I modify it so that I don't hardcode the executable? I'd like to be able to chose what running application gets focus.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  25. #25
    Join Date
    Feb 2003
    Posts
    432


    Did you find this post helpful? Yes | No

    Default

    Have you tried something simple like

    dim TargetAppName as String

    .....


    TargetAppName = "calc.exe"

    .....

    AppActivate Shell(TargetAppName, 1)
    Keith

    www.diyha.co.uk
    www.kat5.tv

  26. #26
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Under most circumstances, SendKeys is not recommended in a production environment.
    This is because the keystrokes are processed by whichever window is currently active
    on the desktop. Obviously this will cause unpredictable behavior in case another app
    receives the focus while your code is processing the Sendkeys statement.
    If you're unlucky, the keystrokes sent to application may cause all documents
    to be deleted or the hard drive to be formatted.
    So try to avoid Sendkeys at all cost.

    Best regards,

    Luciano

  27. #27
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    Luciano, The whole reason for this application is to send keystrokes to an application.

    Keith, That's how the Help file does it, I had shrunk it down a bit for testing.


    I was hoping there was a sort of 'list' feature of running applications that I could scroll through; something like ALT-TAB. But now that I think more about it, similar applications make the user select the executable (like the Profiler for the Logitech wheel). By forcing focus on a selected executable, I reduce that danger that Luciano brought up.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  28. #28
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    I ended up storing the executable, at least it works.


    Any idea why this is seen by a game:

    SendKeys "{F3}", False

    But this is not:

    SendKeys "{LEFT}", False


    The Help file lists the Left Arrow as a special character just like F3, but it doesn't work for some reason.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  29. #29
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Games use DirectInput. (DirectX).

    Best regards,

    Luciano

  30. #30
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    Yes, but games also use keyboard input.

    I found several good tutorial links on a gaming site:
    http://www.vbtutor.net/vbtutor.html
    http://cuinl.tripod.com/tutorials.htm
    http://www.vbcode.com/
    http://www.planet-source-code.com/

    Not sure if they were mentionned above.

    One guy in those tutorials recommended using the SendInput feature instead of the "basically broken" SendKeys.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  31. #31
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    I'm starting to see what people have moaned about MS products. Most of the links I've read relating with SendKeys says that it is not reliable, if it works at all.

    This place describes using a more flexible keyboard API:
    http://www.vbaccelerator.com/home/VB...PI/article.asp

    Still reading, how it's understandable.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  32. #32
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695


    Did you find this post helpful? Yes | No

    Default

    Hi,

    Normal windows programs

    When a key is pressed, the keyboard driver passes the keystroke
    to Windows and the message is saved in the system message queue.
    Windows then transfers the message from the system queue to the
    queue of the program with the "input focus" where the keystroke
    is then processed.

    * * *

    Games using DirecX

    DirectInput (see DirectX) works directly with the keyboard driver.
    So when you play, the game does not get keystrokes as a normal
    Windows message.

    * * *

    Be aware that posts in forums can be very old. (Not about VB6 SP6).
    Also most of these post are written by people like me and you.

    Best regards,

    Luciano

  33. #33
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    I'm still not sure how DirectInput games will come into play with my machine. I guess I'll have to cross that bridge when I fall in the water. I suppose I can learn about DirectInput later and add in code to deal with those games at that point. I'll add a flag right away in my database; Input Type (DirectInput or Keyboard Input).

    I tried that guy's demo, pasted the Class Module directly in my project, I called his version of SendKeys with "{LEFT}" and the Left Arrow worked like a charm in my game.

    WOOHOO! I'm back on track.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  34. #34
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,596


    Did you find this post helpful? Yes | No

    Default

    Lots of small debugging completed. I've found out the importance of nulls and properly initializing fields.

    One thing is odd, the custom SendKeys logic above works like a charm except for one thing:

    ^%{DELETE}

    I would have expected the Task Manager screen to pop up but apparently it doesn't work that way. Is there some sort of parameter that disables CTRL-ALT-DELETE by default or something like that?

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

Similar Threads

  1. Replies: 5
    Last Post: - 24th August 2006, 21:59
  2. Visual Basic 6 question
    By Christopher4187 in forum Off Topic
    Replies: 5
    Last Post: - 3rd July 2006, 13:06
  3. Visual Basic 6 and Pic com
    By shawn in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 15th September 2005, 05:21
  4. Output PIC module
    By freelancebee in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th September 2005, 20:10
  5. '877 and Visual Basic 6
    By Tomas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th March 2004, 02:31

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts