For MartinLiss Question on the project i uploaded http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28354481.html

http://www.experts-exchange.com/Programming/Languages/Visual_Basic/Q_28354481.html
I hope you can help me with this.
As i stated before I am trying to use code a coder i hired to write this new project. Most is over my head. See the attached rtf file
keno-problems.zip
isnoend2001Asked:
Who is Participating?
 
Martin LissOlder than dirtCommented:
I've found the solution to the problem you described where lblMarked gets reset. To fix it add lines 31 to 34 in this code in frmCleo.
'---------------------------------------------------------------------------------------
' Procedure : UpdateNumber
' DateTime  : 12/18/2013 09:08
' Author    : Robert Moore
' Purpose   :
'---------------------------------------------------------------------------------------
'
Private Sub UpdateNumber(pindex As Integer, pX As Single, pY As Single, Optional pInitialiseDrag As Boolean = False)
Dim lRow As Integer, lCol As Integer, lBorderColour As Long, lForeColour As Long
Dim thisImage As StdPicture


   On Error GoTo UpdateNumber_Error

   If KenoBoards(mCurrentBoardIndex).SelectedCount = MAX_SELECTIONS And mSelecting Then
        Exit Sub
    End If
 
 
    If pInitialiseDrag Then
        flexCleo.Drag vbBeginDrag
    End If
           
    CellFromIndex pindex, lRow, lCol
    
    If mSelecting = KenoNumbers(pindex).Selected Then
     'Nothing to do - item is already selected or unselected
    Else
       If mSelecting Then
          Set thisImage = imgSelNotHit.Picture
          'new
          If Val(lblMarked.Caption) > 0 Then
            KenoBoards(mCurrentBoardIndex).SelectedCount = Val(lblMarked.Caption)
          End If
          
          KenoBoards(mCurrentBoardIndex).SelectedCount = KenoBoards(mCurrentBoardIndex).SelectedCount + 1
          
          With flexCleo
            .Row = lRow
            .Col = lCol
            .RowSel = lRow
            .ColSel = lCol
            Set .CellPicture = thisImage
            .CellForeColor = vbYellow
          End With
          
          
           ' select the same cells in frmcleobonus
'           With frmCleoBonus.flexCleoBonus
'           .Row = lRow
'            .Col = lCol
'            .RowSel = lRow
'            .ColSel = lCol
'            Set .CellPicture = frmCleoBonus.imgChoosen
'            .CellForeColor = vbYellow
'            End With
'          gBonusRow = iRow
'          gBonusCol = iCol
       Else
          Set thisImage = imgCellBG.Picture 'reset to unselected
          KenoBoards(mCurrentBoardIndex).SelectedCount = KenoBoards(mCurrentBoardIndex).SelectedCount - 1
          mUnSeletedNumber = True 'rm12-18-13
          With flexCleo
            .Row = lRow
            .Col = lCol
            .RowSel = lRow
            .ColSel = lCol
            Set .CellPicture = thisImage
            .CellForeColor = vbWhite
            
          End With
       End If
       
       lblMarked.Caption = "" & KenoBoards(mCurrentBoardIndex).SelectedCount
       mNumberofSpotsSelected = KenoBoards(mCurrentBoardIndex).SelectedCount
       'mNumberofSpotsSelected = Val(lblMarked)
       gintSelected = Val(lblMarked)
       KenoNumbers(pindex).Selected = mSelecting
       UpdateFlexStatus 'rm12-18-13
    End If

   On Error GoTo 0
   Exit Sub

UpdateNumber_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure UpdateNumber of Form frmCleo"
    
End Sub

Open in new window


I highlighted frmCleo above because you may not realize it but frmKeno seems to be an almost exact (it could be exact) copy of frmCleo. Why has that been done rather than just adding code to frmCleo to do whatever special thing(s) you do in frmKeno?

Should i upload the latest code-project?
Yes, make the change above and then upload it again.

Finally you'll find my email address in my profile. Send me an email because I'd like to talk with you offline.
0
 
Martin LissOlder than dirtCommented:
I'm looking at it now.
0
 
Martin LissOlder than dirtCommented:
When I open the saved game, frmCleoBonus opens. Is that supposed to happen?

Another problem that I've seen in your project and that is that sometimes when I select a number, two numbers are selected. Does that happen to you?

A general problem is that you have many dead ( = unused) variables and procedures in your code which makes it more difficult to maintain.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
isnoend2001Author Commented:
Thanks for your help
When I open the saved game, frmCleoBonus opens. Is that supposed to happen?
No. seems i remember that happening, don't remember why or how i fixed it

Another problem that I've seen in your project and that is that sometimes when I select a number, two numbers are selected. Does that happen to you?
2 numbers should only be selected by dragging. I will check

A general problem is that you have many dead ( = unused) variables and procedures in your code which makes it more difficult to maintain.
Yes and a lot of subs, functions, this comes from me coping the hired coders code

Should i upload the latest code-project?
0
 
isnoend2001Author Commented:
Another problem that I've seen in your project and that is that sometimes when I select a number, two numbers are selected. Does that happen to you?
2 numbers should only be selected by dragging. I will check

This does not happen to me
0
 
Martin LissOlder than dirtCommented:
When I click the numbers rapidly VB may think I'm dragging.
0
 
isnoend2001Author Commented:
Thanks

I added the code you provided to

Sub UpdateNumber
it seems a lot closer however unselecting marked numbers seems to need tweaking.
I will upload the version i am coding now.
0
 
isnoend2001Author Commented:
project uploaded
For-EE2-4-14.zip
0
 
Martin LissOlder than dirtCommented:
I can't get over wanting to fix the problem I described in post ID: 39833232. I believe you can reproduce the problem if you select a number and then quickly release the mouse while still moving the cursor. That would be easy to fix using the flexCleo's MouseUp event but for some reason that event doesn't fire when the mouse is release. Let me know if you can reproduce the problem and if you can would you be willing to have the code changed so that the "dragging" only happens when the Right mouse button is clicked?
0
 
isnoend2001Author Commented:
Thanks Martinliss
I am replying to your email now. I will be back
0
 
isnoend2001Author Commented:
Thanks MartinLiss
I don't have that problem, but it seems that clicking and dragging on frmKeno is smoother.
I copied the code from it, don't see why it is different. you can open that form from frmCleo
by clicking the the button 20 Card keno top left of form
0
 
Martin LissOlder than dirtCommented:
Here are some suggestions for improving your code.

Naming variables and controls
Note that this is the way I name them and while it's not the only way, it is probably the most popular way. You can choose some other way if you like, but the important thing is to be consistent. When you name a variable properly you should be able to tell three things at a glance:
1. Where the variable is defined (doesn't apply to controls)
2. What type of variable or control it is
3. What the variable or control is for (at least in general)

My variables look like this
stttxxxxxxxxxxxxxxx

where 's' is the scope of the variable, 'ttt' is the type and 'xxx' is the descriptive name. Some examples are:

1) intSelectedCount: Here the "g" indicates that the variable is defined in a code module and hence has global scope. Variables defined in code modules are normally defined as Public.  The "int" (which is always all lower case) indicates that the variable is defined as Integer. Some other possibilities are:
str = String
lng = Long
dbl = Double
cur = Currency
etc.
and for controls
lbl = Label
frm = Form
fra = Frame
grd = some type of grid ("flex" is fine and actually may be better)
txt = Textbox
etc.

b = Boolean. Sometimes "is" is used for readability. For example If isSelected Then blah

2) mbValueSelected: The "m" indicates that the variable is defined at the top of a form module. Variables of this type should always be defined as Private. (Dim is functionally the same as Private but it's use for form-level variables is frowned on).

3) intCount: The lack of a g or m prefix indicates that the variable is local to the Sub or Function where it is defined.

Formatting Code
Properly formatting code makes the code much easier to follow. Consider the following small coder snippet.
      If mSessionRunsMade = False Then
      lblCredit = gCleoNewGameCredits 'no runs made so load start credits to lblcredit
      lblBet = 0
      If Not InStr(lblCredit, "$") Then
      lblCredit = CreditMode1String(lblCredit, mBetMode)
       Else
        lblCredit = CreditMode0String(lblCredit, mBetMode)
        End If
     End If

Open in new window

As is it's not too difficult to follow but at first glance it does take a second or two to understand what's going one and seconds can add up. Here is the same code properly formatted and I think you'll agree it's easier to follow.
      If mSessionRunsMade = False Then
        lblCredit = gCleoNewGameCredits 'no runs made so load start credits to lblcredit
        lblBet = 0
        If Not InStr(lblCredit, "$") Then
            lblCredit = CreditMode1String(lblCredit, mBetMode)
        Else
            lblCredit = CreditMode0String(lblCredit, mBetMode)
        End If
     End If

Open in new window

0
 
isnoend2001Author Commented:
thanks for the info MartinLiss
Just noticed that if in auto play mode and a win is adding up(rotating Labels-Sound) then
the next run starts before the labels are done rotating so i need to make a boolean for the next run to wait until win is added up
After reading you information
I am thinking mbolWaitforWintoFinish as boolean
m for form level
bol for boolean
What do you think ?
0
 
Martin LissOlder than dirtCommented:
I've never seen "bol" used for Boolean and I think "b" is better but as long as you are consistent it's OK. I also think that mbolWaitingforWintoFinish or mbolRotationFinished would be better because it would "read" better as in

If mbolWaitingorWintoFinish Then...

or

If mbolRotationFinished Then...
0
 
isnoend2001Author Commented:
Thanks
i also think b is better
btw:
Every one of my functions, subs will have error handlers and line numbers before project is done
0
 
isnoend2001Author Commented:
What do you think of this:
Sub StartCleo()
 Dim Replay As Boolean
Restart:
  If mbWaitforWinToFinish = True Then
    Do Until mbWaitforWinToFinish = False
    DoEvents
loop
  End If
0
 
isnoend2001Author Commented:
Hi MartinLiss
I am in the process of renaming variables and formatting code
How would you name this form level variable ?
Dim sndData() As Byte
0
 
Martin LissOlder than dirtCommented:
Private mbytData As Byte

"Data" could be changed to something more meaningful.
0
 
Martin LissOlder than dirtCommented:
Sub StartCleo()
 Dim Replay As Boolean
Restart:
  If mbWaitforWinToFinish = True Then
    Do Until mbWaitforWinToFinish = False
Is there some more code here? There should be.
    DoEvents
loop
  End If
0
 
isnoend2001Author Commented:
Thanks
0
 
isnoend2001Author Commented:
I put that as a stall to wait
When auto play was going i noticed that on a win the win labels rotate the amount
of the win and play a sound. I noticed that the next randomize would start selecting numbers
before the numbers were done rotating so i put this after the timer was done rotating the labels:
mbWaitforWinToFinish = False
It seems to fix the problem
0
 
Martin LissOlder than dirtCommented:
It seems to fix the problem

That's good:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.