isnoend2001
asked on
Problem with un-selecting numbers for keno game(stumped)
problem Hired a coder from FreeLancer a few month ago to write
Code for a keno game. Can no longer find him.
There are 80 numbers on the keno board.
The numbers are selected by dragging the mouse over the numbers.
this happens no matter which numbers are selected not just the first 5
In the jpg I have selected the first 5 numbers by dragging the mouse.
The problem arrises when dragging to unselect the numbers.The wrong numbers are displayed in the cells. It works correctly when clicking the indivual cells to unselect them. but dragging displays the problem(see jpg)
this happens no matter which numbers are selected not just the first 5
I think it is inthe following code which is beyond my abilities.
Code for a keno game. Can no longer find him.
There are 80 numbers on the keno board.
The numbers are selected by dragging the mouse over the numbers.
this happens no matter which numbers are selected not just the first 5
In the jpg I have selected the first 5 numbers by dragging the mouse.
The problem arrises when dragging to unselect the numbers.The wrong numbers are displayed in the cells. It works correctly when clicking the indivual cells to unselect them. but dragging displays the problem(see jpg)
this happens no matter which numbers are selected not just the first 5
I think it is inthe following code which is beyond my abilities.
Private Sub DeSelectCurrentBoard()
Dim iRow As Integer, iCol As Integer
With flexBoardSelector
If mCurrentBoardIndex > 0 Then
CellFromIndex mCurrentBoardIndex, iRow, iCol
.Row = iRow: .Col = iCol
.CellBackColor = vbWhite
End If
End With
End Sub
Private Sub flexKenoBoard_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
Dim OverCentreX As Boolean, OverCentreY As Boolean, ValidMouseOver As Boolean
Dim thisIndex As Integer
With flexKenoBoard
OverCentreX = Abs(Y - (.RowPos(.MouseRow) + (BOARD_CELL_WIDTH / 2))) < CELL_MOUSE_SENSITIVITY
OverCentreY = Abs(X - (.ColPos(.MouseCol) + (BOARD_CELL_WIDTH / 2))) < CELL_MOUSE_SENSITIVITY
ValidMouseOver = OverCentreX And OverCentreY
If ValidMouseOver And mranddonenobet = False Then
thisIndex = IndexFromCell(flexKenoBoard.MouseRow, flexKenoBoard.MouseCol)
'Store the card value to available for reuse - KVS - v1.x
clval = thisIndex
UpdateNumber IndexFromCell(.MouseRow, .MouseCol), X, Y, False
End If
End With
End Sub
Private Sub flexKenoBoard_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim thisIndex As Integer
If Button = vbLeftButton Then
thisIndex = IndexFromCell(flexKenoBoard.MouseRow, flexKenoBoard.MouseCol)
'Store the card value to available for reuse - KVS - v1.x
clval = thisIndex
mSelecting = Not KenoNumbers(thisIndex).Selected
UpdateNumber thisIndex, X, Y, True
End If
End Sub
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
If mCurrentBoardIndex = 0 Then Exit Sub 'Check this KVS
'to check Bet before selecting numbers - KVS - v1.8
' If KenoBoards(mCurrentBoardIndex).Stake = 0 And KenoBoards(mCurrentBoardIndex).SelectedCount = 0 Then
' MsgBox "No bet placed"
' Exit Sub
' End If
If KenoBoards(mCurrentBoardIndex).SelectedCount = MAX_SELECTIONS And mSelecting Then
Exit Sub
End If
If mranddonenobet = True Then
If mSavedfileIsDirty = False Then
mNewBetPlaced = True
mSavedfileIsDirty = True 'To check Save or NOT
Call Save_tofile_Write_INI
If mIsDirty = False Then
mNewBetPlaced = False
Exit Sub 'User clicked Cancel
Else
mranddonenobet = False
mNewBetPlaced = False
Call Clear_gridCardStats
pInitialiseDrag = False
End If
End If
End If
'KVS - v2.9.1
If pInitialiseDrag Then
flexKenoBoard.Drag vbBeginDrag
End If
If mSelecting = KenoNumbers(pindex).Selected Then
'Nothing to do - item is already selected or unselected
Else
KenoNumbers(pindex).AssignedLetters = Replace(KenoNumbers(pindex).AssignedLetters, KenoBoards(mCurrentBoardIndex).Letter, vbNullString)
'Set the selected Char to the variable - KVS - v1.x
sel_text_val = KenoBoards(mCurrentBoardIndex).Letter
CellFromIndex pindex, lRow, lCol
If mSelecting Then
lBorderColour = KenoBoards(mCurrentBoardIndex).Colour
lForeColour = vbWhite
KenoNumbers(pindex).AssignedLetters = KenoNumbers(pindex).AssignedLetters & KenoBoards(mCurrentBoardIndex).Letter
KenoBoards(mCurrentBoardIndex).SelectedCount = KenoBoards(mCurrentBoardIndex).SelectedCount + 1
Set thisImage = imgBlueSpot.Picture
'As user have to make bet before selecting a number - KVS - v1.8
' If KenoBoards(mCurrentBoardIndex).Stake = 0 Then
' cmdBetMore_Click
' End If
Else
lBorderColour = vbWhite
lForeColour = vbBlack
KenoBoards(mCurrentBoardIndex).SelectedCount = KenoBoards(mCurrentBoardIndex).SelectedCount - 1
Set thisImage = imgCellBG.Picture
'Reset the value back - KVS - v1.x
flexKenoBoard.Text = clval
End If
With flexKenoBoard
.Row = lRow: .Col = lCol
.RowSel = lRow: .ColSel = lCol
Set .CellPicture = thisImage
.Text = clval
'If click, set the text to selected Char - KVS - v1.x
If mSelecting Then .Text = sel_text_val
.CellBackColor = lBorderColour
.CellForeColor = lForeColour
End With
KenoNumbers(pindex).Selected = mSelecting
flexStatus.TextMatrix(KenoBoards(mCurrentBoardIndex).Index, 2) = IIf(KenoBoards(mCurrentBoardIndex).SelectedCount > 0, KenoBoards(mCurrentBoardIndex).SelectedCount, vbNullString)
'To load flexonecard when clicking the letter for which numbers are selected already - KVS - V1.6
If FlexOneCard.Visible = True And flexStatus.TextMatrix(KenoBoards(mCurrentBoardIndex).Index, 1) <> "" Then
Call flexoncecard_upd(flexStatus.TextMatrix(KenoBoards(mCurrentBoardIndex).Index, 1), mCurrentBoardIndex, KenoBoards(mCurrentBoardIndex).SelectedCount)
'lblRuns.Caption = 0 'KVS - v2.6
gridCardStats.TextMatrix(5, 1) = 0
End If
PlaySoundData SoundSelect(0), 0, SND_MEMORY Or SND_ASYNC Or SND_NODEFAULT
End If
If getCardCountSelected >= 2 Then
Call ShowOneCard
Else
'Its showing ALL flex grid while selcting the numbers for the first letter - KVS - V1.6
'Call ShowAllCards
'Added to show flexgrip for single card selection - KVS - V1.6
Call ShowOneCard
End If
Call DisplayCardsPlayed
End Sub
Private Function getCardCountSelected() As Integer
Dim i As Integer
Dim lCount As Integer
lCount = 0
For i = 1 To 20
If KenoBoards(i).SelectedCount > 0 Then
lCount = lCount + 1
End If
Next i
ASKER
Thanks for the reply, I think you are probably right, but i am stumped as what needs changing
I feel your pain - it can be hard to work out what someone else had in mind and the approach they have taken.
Can you provide any more code or the actual page/app code itself? That would make it easier to follow what the code does and therefore find where the incorrect starting number is used.
Can you provide any more code or the actual page/app code itself? That would make it easier to follow what the code does and therefore find where the incorrect starting number is used.
ASKER
Thanks duttcom
I posted at another site and got this reply:
try changing
flexKenoBoard.Text = clval
to
flexKenoBoard.Text = clval - 1
this seems to have fixed the dragging accross cols,
but not accross rows
I will attach the form
I really do appreciate the helpKeno.zip
I posted at another site and got this reply:
try changing
flexKenoBoard.Text = clval
to
flexKenoBoard.Text = clval - 1
this seems to have fixed the dragging accross cols,
but not accross rows
I will attach the form
I really do appreciate the helpKeno.zip
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for taking the time to troubleshoot this problem. I will try your suggestions, hopefully I can get past this issue
When the numbers are de-selected, they are being reset to one number higher because they are being counted from 1 not 0, therefore the first cell becomes 1+1 = 2 instead of 0+1 = 1