Link to home
Start Free TrialLog in
Avatar of isnoend2001
isnoend2001Flag for United States of America

asked on

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

https://www.experts-exchange.com/questions/28354481/make-a-borderless-form-stay-behind-all-other-forms.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
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

I'm looking at it now.
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.
Avatar of isnoend2001

ASKER

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?
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
When I click the numbers rapidly VB may think I'm dragging.
ASKER CERTIFIED SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
project uploaded
For-EE2-4-14.zip
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?
Thanks Martinliss
I am replying to your email now. I will be back
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
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

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 ?
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...
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
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
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
Private mbytData As Byte

"Data" could be changed to something more meaningful.
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
Thanks
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
It seems to fix the problem

That's good:)