LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Running code.

Hello,

I have been using VB and C# in Visual Studio for a long time but never
used it with Excel.
I have an Excel sheet with 16 images. Each one in each cell and having
a name of img1, img2, ....

I have some VB code which I want to run. When I run it am I asked for
a Macro name.

Could someone, please, give me some tips on how to run this game code?

Here is the code:

Option Explicit

' TYPES

' GameType
Type GameType
img(1 To 6, 1 To 6) As String
LastRow As Integer
LastCol As Integer
Score As Integer
End Type ' GameType


' VARIABLES
Public game As GameType


' METHODS

' MyWait
Sub MyWait(ByVal wt As Single)
Dim t As Single
t = Timer
Do
Loop Until Timer - t wt
End Sub ' MyWait

' Positioning
Sub Positioning(ByRef game As GameType, ByVal r As Integer, ByVal c As
Integer)
Dim hc As Single, hf As Single, wc As Single, wf As Single
Dim nf As String
On Error GoTo fim
With Range("tabuleiro")
hc = .Cells(r, c).Height
wc = .Cells(r, c).Width
nf = game.img(r, c)
hf = ActiveSheet.Shapes(nf).Height
wf = ActiveSheet.Shapes(nf).Width
ActiveSheet.Shapes(nf).Top = .Cells(r, c).Top + (hc - hf) / 2
ActiveSheet.Shapes(nf).Left = .Cells(r, c).Left + (wc - wf) / 2
End With
fim:
End Sub ' Positioning

' Hide
Sub Hide(ByRef game As GameType, ByVal r As Integer, ByRef c As
Integer)
With game
ActiveSheet.Shapes(.img(r, c)).Visible = False
End With
DoEvents
End Sub ' Hide

' Show
Sub Show(ByRef game As GameType, ByVal r As Integer, ByRef c As
Integer)
With game
ActiveSheet.Shapes(.img(r, c)).Visible = True
End With
DoEvents
End Sub ' Show

' IsVisible
Function IsVisible(ByRef game As GameType, ByVal r As Integer, ByRef c
As Integer) As Boolean
With game
IsVisible = ActiveSheet.Shapes(.img(r, c)).Visible
End With
End Function ' IsVisible

Thanks,
Miguel
 
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
How can I update VBA code in a module that is running my VBA code? Gummy Excel Programming 3 June 12th 07 06:26 PM
Code is not running Keith Excel Programming 5 November 6th 06 03:59 PM
how to prevent code running when in a worksheet code Corey Excel Programming 5 August 13th 06 08:52 AM
Running Code from Add-Ins DeanO Excel Programming 1 October 27th 05 05:20 PM
running code mark New Users to Excel 3 March 14th 05 09:14 AM


All times are GMT +1. The time now is 07:40 PM.

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

About Us

"It's about Microsoft Excel"