Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need Help Using cards.dll with Excel VBA
Can anyone tell me how to get playing cards from cards.dll (or cards32.dll)
and put them om a userform? I've found references on how to do it with Visual Basic or C but I'm not smart enough to get it to work with VBA. Thanks, Ed |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need Help Using cards.dll with Excel VBA
I don't know what cards.dll is. Usually, to use these in VBA you'd set a
reference to it -- in the IDE, select Tools / References "Edward Braswell" wrote: Can anyone tell me how to get playing cards from cards.dll (or cards32.dll) and put them om a userform? I've found references on how to do it with Visual Basic or C but I'm not smart enough to get it to work with VBA. Thanks, Ed |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need Help Using cards.dll with Excel VBA
Ed,
Whilst it's in C, it's understandable: http://www.catch22.net/tuts/cardtut.asp NickHK "Edward Braswell" wrote in message ... Can anyone tell me how to get playing cards from cards.dll (or cards32.dll) and put them om a userform? I've found references on how to do it with Visual Basic or C but I'm not smart enough to get it to work with VBA. Thanks, Ed |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need Help Using cards.dll with Excel VBA
Hi Edward,
Here is an example of using the Card dlls in a worksheet. '==================================== Option Explicit Private Declare Function FreeLibrary& Lib "kernel32" _ (ByVal hLibModule As Long) Private Declare Function DeleteObject Lib "gdi32" _ (ByVal hObject As Long) As Long Private Declare Sub Sleep Lib "kernel32" _ (ByVal dwMilliseconds As Long) Private Declare Function FindWindow Lib "user32" _ Alias "FindWindowA" (ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Private Declare Function CloseClipboard Lib "user32" _ () As Long Private Declare Function OpenClipboard Lib "user32" _ (ByVal hwnd As Long) As Long Private Declare Function EmptyClipboard Lib "user32" _ () As Long Private Declare Function SetClipboardData Lib "user32" _ (ByVal wFormat As Long, ByVal hMem As Long) As Long Private Declare Function LoadBitmapBynum& Lib "user32" _ Alias "LoadBitmapA" (ByVal hInstance As Long, _ ByVal lpBitmapName As Long) Private Declare Function LoadLibrary& Lib "kernel32" _ Alias "LoadLibraryA" (ByVal lpLibFileName As String) Public Sub CardInCell(rCell As Range, _ Card As String, Optional AdjustmentMode As Long) Dim lSuite As Long, iCourt As Long Dim hModul As Long, hBitmap As Long Dim hMyWnd As Long, lIndex As Long Dim lZeile As Long, lSpalte As Long Dim sName As String, oCard As Shape Dim sDummy As String Select Case UCase(Left(Card, 1)) Case "C": lSuite = 1 'Clubs" Case "D": lSuite = 2 'Diamonds Case "H": lSuite = 3 'Hearts Case "S": lSuite = 4 'Spades Case Else: lSuite = 5 'Reverse End Select sDummy = UCase(Mid(Card, 2, 2)) Select Case sDummy Case "T": iCourt = 10 'Ten Case "J": iCourt = 11 'Jack Case "Q": iCourt = 12 'Queen Case "K": iCourt = 13 'King Case "A": iCourt = 1 'Ace Case Else If IsNumeric(sDummy) Then iCourt = sDummy If iCourt 13 Then iCourt = 13 Else iCourt = 1 End If End Select hMyWnd = FindWindow(vbNullString, Application.Caption) hModul = LoadLibrary("Cards.dll") If hModul = 0 Then hModul = LoadLibrary("Cards32.dll") OpenClipboard hMyWnd EmptyClipboard hBitmap = LoadBitmapBynum(hModul, (lSuite - 1) * 13 + iCourt) SetClipboardData 2, hBitmap sName = rCell.Worksheet.Name With Worksheets(sName) sName = rCell(1, 1).Address For Each oCard In .Shapes If oCard.Name = sName Then oCard.Delete: Exit For End If Next .Select .Paste Set oCard = .Shapes(.Shapes.Count) oCard.Left = rCell(1, 1).Left oCard.Top = rCell(1, 1).Top oCard.Name = sName Select Case AdjustmentMode Case 1 'Adjust to cell height & width oCard.LockAspectRatio = msoFalse oCard.Width = rCell(1, 1).Width oCard.Height = rCell(1, 1).Height Case 2 ' adjust to cell width oCard.Width = rCell(1, 1).Width Case Else ' Adjust to cell heght oCard.Height = rCell(1, 1).Height End Select End With DeleteObject hBitmap CloseClipboard FreeLibrary hModul End Sub '==================================== Sub DemoCardDeck() Dim Arr As Variant Dim Arr2 As Variant Dim i As Long Dim j As Long Arr = Array("T", "J", "Q", "K", "A", 2, 3, 4, 5, 6, 7, 8, 9) Arr2 = Array("H", "D", "C", "S") Application.ScreenUpdating = False ActiveWorkbook.Sheets.Add.Name = "Demo Card Deck" Columns("A").Resize(, 13).ColumnWidth = 12 Rows(1).Resize(4).RowHeight = 85 For i = LBound(Arr2) To UBound(Arr) For j = LBound(Arr) To UBound(Arr2) CardInCell ActiveSheet.Cells(j + 1, i + 1), _ Arr2(j) & Arr(i), 1 Next Next Application.ScreenUpdating = False End Sub I have not attempted to adapt this for use in a userform control. --- Regards, Norman "Edward Braswell" wrote in message ... Can anyone tell me how to get playing cards from cards.dll (or cards32.dll) and put them om a userform? I've found references on how to do it with Visual Basic or C but I'm not smart enough to get it to work with VBA. Thanks, Ed |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
EXCEL Wild Cards | New Users to Excel | |||
Mass Changes in Excel using Wild Cards or other | Excel Discussion (Misc queries) | |||
How do I make note cards from an inventory in excel? | Excel Discussion (Misc queries) | |||
how to subtract time cards in minutes in excel | Excel Worksheet Functions | |||
How do i change info in all my cust cards in excel in one go | Excel Discussion (Misc queries) |