+ Reply to Thread
Results 1 to 2 of 2

How can I show the results of the following code?

  1. #1
    Registered User
    Join Date
    10-12-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    2

    How can I show the results of the following code?

    Hi all,

    I have written the following using winscard.dll in Excel VBA.

    When I compile it I get no errors however I cannot get it to display anything on the form.

    This is all in the userform1.

    -----------------------------------------------------------------------

    Private Const SCARD_SCOPE_USER As Long = &H0
    Private Const SCARD_SCOPE_SYSTEM As Long = &H2
    Private Const SCARD_SHARE_SHARED As Long = &H2
    Private Const SCARD_SHARE_EXCLUSIVE As Long = &H1
    Private Const SCARD_SHARE_DIRECT As Long = &H3
    Private Const SCARD_PROTOCOL_T0 As Long = &H1
    Private Const SCARD_PROTOCOL_T1 As Long = &H2

    Private Const SCARD_DEFAULT_READERS As String = "SCard$DefaultReaders\000"

    Private Declare PtrSafe Function SCardEstablishContext Lib "winscard.dll" (ByVal dwScope As Long, _
    ByVal pvReserved1 As Long, _
    ByVal pvReserved2 As Long, _
    ByRef phContext As SCARDCONTEXT _
    ) As Long

    Private Declare PtrSafe Function SCardReleaseContext Lib "winscard.dll" (ByRef phContext As SCARDCONTEXT) As Long

    Private Declare PtrSafe Function SCardConnect Lib "winscard.dll" (ByRef phContext As SCARDCONTEXT, _
    ByVal dwShareMode As Long, _
    ByVal szReader As String, _
    ByVal dwPreferredProtocols As Long, _
    ByRef phCard As Long, _
    ByRef pdwActiveProtocol As Long _
    ) As Long

    Private Declare PtrSafe Function SCardListReaders Lib "winscard.dll" (ByRef phContext As SCARDCONTEXT, _
    ByVal dwShareMode As Long, _
    ByVal mszGroups As String, _
    ByRef mszReaders As String, _
    ByRef pcchReaders As Long _
    ) As Long

    Private Type SCARDCONTEXT
    CardContext1 As Long
    ReaderName As String
    End Type

    Sub GetContext()

    Dim lReturn As Long
    Dim RSVD1 As Long, RSVD2 As Long
    Dim myContext As SCARDCONTEXT

    lReturn = SCardEstablishContext(SCARD_SCOPE_USER, RSVD1, RSVD2, myContext)

    Debug.Print "SCardEstablishContext: Return =" & lReturn & "" _
    ; " myContext.CardContext1 = " & myContext.CardContext1 & _
    " myContext.ReaderName = " & Chr(34) & myContext.ReaderName & Chr(34)

    Dim ListOfReaders As String, lenListOfReaders As Long

    lReturn = SCardListReaders(myContext, SCARD_SHARE_SHARED, SCARD_DEFAULT_READERS, ListOfReaders, lenListOfReaders)

    Debug.Print "SCardListReaders: Return =" & lReturn & _
    " ListOfReaders = " & Chr(34) & ListOfReaders & Chr(34) & _
    " lenListOfReaders = " & lenListOfReaders

    lReturn = SCardReleaseContext(myContext)
    Debug.Print "SCardReleaseContext: Return =" & lReturn

    End Sub



    Private Sub UserForm_Click()

    End Sub


    ---------------------------------------------

    Some help would be appreciated.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How can I show the results of the following code?

    Hello and welcome to the forum. Unfortunately your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title go to your first post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    In addition when posting code also note our rule about wrapping any code in CODE tags so that it indents correctly.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. vba code to show rowsource and then filter to show certain returns
    By zak.horrocks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-02-2014, 10:48 AM
  2. [SOLVED] Using VLookup but results show formula instead of results...
    By excel me in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 11-28-2013, 09:40 PM
  3. [SOLVED] how to add counter in msgbox to show remain times the message will show vba code
    By sspreyer in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-25-2013, 06:46 AM
  4. How to Show ALT+ results
    By PosseJohn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-29-2013, 03:35 PM
  5. [SOLVED] VBA code needed to show the results through UserForm
    By krjoshi in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-01-2012, 04:19 PM
  6. Get excel 2007 show results in notepad through VBA code
    By PBMClubber in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-15-2010, 06:58 AM
  7. Replies: 6
    Last Post: 08-29-2005, 07:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1