Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
EXCEL Wild Cards NPVSRUS New Users to Excel 2 July 7th 08 10:26 PM
Mass Changes in Excel using Wild Cards or other Rev Les Hall Excel Discussion (Misc queries) 3 June 2nd 08 05:03 PM
How do I make note cards from an inventory in excel? Quik Excel Discussion (Misc queries) 8 February 23rd 06 09:10 PM
how to subtract time cards in minutes in excel excelsior Excel Worksheet Functions 1 June 6th 05 05:44 AM
How do i change info in all my cust cards in excel in one go Michaelr Excel Discussion (Misc queries) 2 May 17th 05 01:18 PM


All times are GMT +1. The time now is 09:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"