Click here to Skip to main content
15,347,523 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionhelp edit config file Pin
Benjamindh8-Jun-22 11:14
MemberBenjamindh8-Jun-22 11:14 
AnswerRe: help edit config file Pin
Dave Kreskowiak8-Jun-22 14:55
mveDave Kreskowiak8-Jun-22 14:55 
QuestionPooling data from database into Listview with timer Pin
SHAHROL AZMI BIN AMZAT25-May-22 22:53
MemberSHAHROL AZMI BIN AMZAT25-May-22 22:53 
AnswerRe: Pooling data from database into Listview with timer Pin
Dave Kreskowiak26-May-22 5:34
mveDave Kreskowiak26-May-22 5:34 
GeneralRe: Pooling data from database into Listview with timer Pin
SHAHROL AZMI BIN AMZAT26-May-22 14:25
MemberSHAHROL AZMI BIN AMZAT26-May-22 14:25 
GeneralRe: Pooling data from database into Listview with timer Pin
Dave Kreskowiak27-May-22 5:37
mveDave Kreskowiak27-May-22 5:37 
GeneralRe: Pooling data from database into Listview with timer Pin
SHAHROL AZMI BIN AMZAT29-May-22 15:53
MemberSHAHROL AZMI BIN AMZAT29-May-22 15:53 
QuestionWinforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Jo_vb.net18-May-22 8:11
MemberJo_vb.net18-May-22 8:11 
Since some weeks i'm working on a german cards game "Schafkopf" [private] demo.

The demo is not bad but somehow my coding drifted away and appears like "Spaghetti code".

The game has 32 cards and 4 players.
For a "SOLO" or "WENZ" the declarer plays against the 3 other players.
A standard game is that the declarer plays with one "Ace" (owned by another player) => 2 play against the other 2.

The computer controls 3 players, one player is the user who can click on one of his cards (which are presented on a dgv).

The problem is that there are many, many loops when checking a players cards and endless "rules" which now are done with
"If, Then, ElseIf ..." statements.

So one of the related functions is > 500 code lines ...

I think I need a better concept, because the existing one is hard to handle, problems are not easy to fix.

Any ideas?

Example for those loops:

Try
         If MyForm.GameOver = True Then Exit Function
         If GameStatus.ToString = "SpielAus" Then MyForm.GameOver = True
         If GameStatus.ToString = "SpielAus" Then Exit Function

         If sHandCards Is Nothing Then
             ' => LeadSuit n.a.
             Debug.Print("ACP 516 sHandCards: Is Nothing")
             Debug.Print("ACP 517 LeadSuitID: '" & LeadSuitID & "'; TrumpCardID: '" & TrumpCardID & "'")
             sHandCards = sTrumpList
         Else
             'sHandCards <> Nothing
             'MessageBox.Show("ACP 525 sHandCards: " & sHandCards.ToString)
             If ContainsHandCardsStandardTrumps(sHandCards) = False Then
                 'MessageBox.Show("ACP 528 sHandCards: " & sHandCards.ToString)
                 If TrumpCardID <> 4 Then sHandCards = sTrumpList
                 If TrumpCardID = 4 Then
                     If sHandCards.ToString.Contains("O") Then
                     Else
                         sHandCards = sTrumpList
                     End If
                 End If
             End If


             If dgv.CurrentCell.Value.ToString.Contains("♠") Or dgv.CurrentCell.Value.ToString.Contains("♥") Or
                dgv.CurrentCell.Value.ToString.Contains("Ⴖ") Or dgv.CurrentCell.Value.ToString.Contains("Ꚛ") Or
                dgv.CurrentCell.Value.ToString = "" Or dgv.CurrentCell.Value Is Nothing Or
                dgv.CurrentCell.Value.ToString = String.Empty Then
                 For Each row As DataGridViewRow In dgv.Rows
                     For n As Integer = 1 To dgv.Columns.Count - 1
                         If row.Cells(n).Value.ToString.Contains(GetLowOfHandCards(row.Cells(n), PlayerID,
                             DeclarerID, GameStatus, sHandCards, TrumpCardID, dgv, MyForm, LeadSuitID)) Then
                             If dgv.CurrentCell.Value.ToString.Contains("♠") Or
                                 dgv.CurrentCell.Value.ToString.Contains("♥") Or
                                 dgv.CurrentCell.Value.ToString.Contains("Ⴖ") Or
                                 dgv.CurrentCell.Value.ToString.Contains("Ꚛ") Or
                                 dgv.CurrentCell.Value.ToString = "" Or
                                 dgv.CurrentCell.Value Is Nothing Or
                                 dgv.CurrentCell.Value.ToString = String.Empty Then

                                 If row.Cells(n).RowIndex = LeadSuitID AndAlso row.Cells(n).RowIndex <>
                                     MyForm.RufAs.CardColor Then
                                     If row.Cells(n).Value.ToString.Contains("O") = False AndAlso
                                         row.Cells(n).Value.ToString.Contains("U") = False Then
                                         SetCurrentCell(dgvCell, dgv, row.Cells(n), row.Cells(0), " ~ " &
                                         (String.Format("Line # {0}", (New StackTrace(New
                                         StackFrame(True))).GetFrame(0).GetFileLineNumber())) & " ~ ")
                                     End If
                                 End If
                             End If
                         End If
                     Next
                 Next
             End If

AnswerRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Gerry Schmitz18-May-22 17:49
mveGerry Schmitz18-May-22 17:49 
GeneralRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Jo_vb.net18-May-22 20:53
MemberJo_vb.net18-May-22 20:53 
GeneralRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Gerry Schmitz19-May-22 6:39
mveGerry Schmitz19-May-22 6:39 
GeneralRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Jo_vb.net22-May-22 7:32
MemberJo_vb.net22-May-22 7:32 
GeneralRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Gerry Schmitz23-May-22 11:44
mveGerry Schmitz23-May-22 11:44 
QuestionRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Eddy Vluggen20-May-22 4:15
professionalEddy Vluggen20-May-22 4:15 
AnswerRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Jo_vb.net20-May-22 5:07
MemberJo_vb.net20-May-22 5:07 
GeneralRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Gerry Schmitz20-May-22 5:30
mveGerry Schmitz20-May-22 5:30 
QuestionRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Eddy Vluggen20-May-22 6:08
professionalEddy Vluggen20-May-22 6:08 
AnswerRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Gerry Schmitz21-May-22 5:36
mveGerry Schmitz21-May-22 5:36 
GeneralRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Jo_vb.net20-May-22 6:21
MemberJo_vb.net20-May-22 6:21 
GeneralRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Jo_vb.net29-May-22 0:42
MemberJo_vb.net29-May-22 0:42 
GeneralRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Gerry Schmitz29-May-22 4:58
mveGerry Schmitz29-May-22 4:58 
GeneralRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Eddy Vluggen20-May-22 6:07
professionalEddy Vluggen20-May-22 6:07 
GeneralRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Jo_vb.net20-May-22 6:26
MemberJo_vb.net20-May-22 6:26 
QuestionRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Eddy Vluggen20-May-22 8:10
professionalEddy Vluggen20-May-22 8:10 
AnswerRe: Winforms VB.Net: Best way to code rules for german cards game "Schafkopf"? Pin
Jo_vb.net20-May-22 8:56
MemberJo_vb.net20-May-22 8:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.