|
I could have just said "There are better examples". If someone said that to me, I would have responded: "And...?"
So, I saw no point in responding as you might suggest.
There, I wasted a message after all.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
|
I do not want to learn Unity or Python.
But I found a WPF project in a CP article with a cards deck where each card is a class object (which shows a card image) called PlayingCard.
I've added some properties which I need for my game rules and migrated all I already had to WPF.
All I have to do now is to re-write > 1000 code lines with the game rules.
But the UI is much better then the old one.
|
|
|
|
|
They were there for "design" ideas. You were asking for "best ways to code" (i.e. "patterns").
(I personally have never written a lick of VB.NET).
But I see you get the idea: find a mouse trap (sample app) and build a better one.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
|
|
|
|
|
Jo_vb.net wrote: but the computer is already playing better than a human with beginner level.
If I only could fix 4 or 5 important remaining issues the pc would reach medium playing level. You programmed it like that! Look into the "Random" object and force it to play a dumb card now and then (once out of five?).
Jo_vb.net wrote: A list or a xml file came also to my mind - I searched for CP articles about rules engine or business rules. Hehe, good idea; those tend to generalize to fit a lot of rules though. You want to keep it simpler; understand the concept enough to build a simpler version of your own.
Remember that "xyz".Contains("c")? Imagine xyz and c coming from a file? It wouldn't be rules based, but halfway. If you can do that, we'll go from there to make actual rules
Jo_vb.net wrote: The last thing would be to have classes for card, hand cards, cards deck, current trick and so on.
But I do not know how to bring together the properties of the classes and my existing rules. You could write multiple classes for a "card"; I'd talk about interfaces at this point if we'd be in class
Jo_vb.net wrote: Any link to an article which may help me would be great. I did not help in any way, and any suggestion may have sounded like homework for school. There's never a library that does exactly what you need. I can only point to CodeProject; they'd help.
Conquer the rules; if you can do that, I'll write an article about depending on classes and having variants
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks a lot for this detailed answer.
But I'm only on a better beginner level in coding...
I use already subs in my loops and I really don't understand how
Quote: Remember that "xyz".Contains("c")? Imagine xyz and c coming from a file? It wouldn't be rules based, but halfway. If you can do that, we'll go from there to make actual rules
could be used for a loop like the following:
If MyForm.RufAs.MeAlreadyPlayed = True Or MyForm.iCoSpieler = -1 Then
For Each row As DataGridViewRow In dgv.Rows
For n As Integer = 1 To dgv.Columns.Count - 1
If MyForm.RufAs.MeAlreadyPlayed = True Or MyForm.iCoSpieler = -1 Then
If MyForm.Trick_Content.CurrentTrickWinner <> MyForm.iCoSpieler AndAlso MyForm.Trick_Content.CurrentTrickWinner <> DeclarerID Then
If n > 0 AndAlso PlayerID <> DeclarerID AndAlso PlayerID <> MyForm.iCoSpieler Then
If TrumpCardID <> 4 Then
If PlayTogether_WenzUsage(dgvCell, PlayerID, DeclarerID, GameStatus, sTrumpList, TrumpCardID, "RufAs", MyForm, LeadSuitID) = True Then
If row.Cells(n).Value.ToString.Contains("U") Then
If ContainsHandCardsStandardTrumps(CStr(sHandCards)) = False Then ' Or sHandCards Is Nothing Then ' Or MyForm.cardLessThan(MyForm.Trick_Content.PossibleWinnerCardString, row.Cells(n).Value.ToString & row.Cells(0).Value.ToString) Then
If LeadSuitID = TrumpCardID AndAlso row.Cells(n).Value.ToString <> String.Empty 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
End If
End If
End If
End If
Next
Next
End If
|
|
|
|
|
Jo_vb.net wrote: But I'm only on a better beginner level in coding... Lots of beginners here; most looking for templates to do their work.
Jo_vb.net wrote: could be used for a loop like the following: Don't worry about the big picture; understand the concept first, then you integrate it into your 'engine'.
Someone hit me if I wrong, but string s = File.ReadAllText(path, appendText, Encoding.UTF8); would load the data of that file into the string called s?
"xyz".Contains("c")
becomes
s.Contains("c")
Where s is then loaded from a file (specified in "path"). This way, the "xyz" isn't hardcoded, but just data in a file. Requires you to read a string from a file. Could you achieve that?
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
I'm in doubt about this approach [the .Contains(s) method is only used in < 10% of the "if - then" statements/rules], but reading a text file line after line is possible.
|
|
|
|
|
The idea is not limited to that method
Bastard Programmer from Hell
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi! Can somebody help me. I am beginner. I have a project and need to update datagridview with image column, using Access databse. I have code for insert new row with image and as I understand it can be modified for updating row. I try to modify, but problem is not working. Now no any alarms or errors occurs, database not changed.
Many thanks un advance.
<pre> Private Sub Btn_Save_Click(sender As Object, e As EventArgs) Handles Btn_Update.Click
Try
If PhotoPictureBox.Image Is Nothing Then
If MsgBox("Are you sure you don't want to upload any pictures?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "Missing picture") Then
Dim CN As New OleDbConnection(connection)
CN.Open()
Dim Int As String
Int = "UPDATE Germany set [Year_of_release]=@year_of_release, [Denomination]=@denomination, [Governing_body]=@governing_body, [Acquired]=@acquired, [Date_of_purchase]=@date_of_purchase, [Course]=@course, [Material]=@material WHERE [ID]=@ID"
Dim cmd As New OleDbCommand(Int, CN)
'cmd.Parameters.Add("@ID", OleDbType.VarChar).Value = IDTextBox.Text
cmd.Parameters.Add("@year_of_release", OleDbType.VarChar).Value = Year_of_releaseDateTimePicker.Value
cmd.Parameters.Add("@denomination", OleDbType.VarChar).Value = DenominationTextBox.Text
cmd.Parameters.Add("@governing_body", OleDbType.VarChar).Value = Governing_bodyTextBox.Text
cmd.Parameters.Add("@acquired", OleDbType.VarChar).Value = AcquiredTextBox.Text
cmd.Parameters.Add("@date_of_purchase", OleDbType.VarChar).Value = Date_of_purchaseDateTimePicker.Value
cmd.Parameters.Add("@course", OleDbType.VarChar).Value = CourseTextBox.Text
cmd.Parameters.Add("@material", OleDbType.VarChar).Value = MaterialTextBox.Text
cmd.ExecuteNonQuery()
cmd.Dispose()
CN.Close()
CN.Dispose()
End If
Else
If imgName <> "" Then
Dim fs As FileStream
fs = New FileStream(imgName, FileMode.Open, FileAccess.Read)
Dim picturebytes As Byte() = New Byte(fs.Length - 1) {}
fs.Read(picturebytes, 0, System.Convert.ToInt32(fs.Length))
fs.Close()
Dim CN As New OleDbConnection(connection)
CN.Open()
Dim Int As String
Int = "UPDATE Germany set [Year_of_release]=@year_of_release, [Denomination]=@denomination, [Governing_body]=@governing_body, [Acquired]=@acquired, [Date_of_purchase]=@date_of_purchase, [Course]=@course, [Material]=@material, [Photo]=@photo WHERE [ID]=@ID"
Dim imgparam As New OleDbParameter()
imgparam.OleDbType = OleDbType.Binary
imgparam.ParameterName = "@photo"
imgparam.Value = picturebytes
Dim cmd As New OleDbCommand(Int, CN)
cmd.Parameters.Clear()
cmd.Parameters.Add("@ID", OleDbType.VarChar).Value = IDTextBox.Text
cmd.Parameters.Add("@year_of_release", OleDbType.VarChar).Value = Year_of_releaseDateTimePicker.Value
cmd.Parameters.Add("@denomination", OleDbType.VarChar).Value = DenominationTextBox.Text
cmd.Parameters.Add("@governing_body", OleDbType.VarChar).Value = Governing_bodyTextBox.Text
cmd.Parameters.Add("@acquired", OleDbType.VarChar).Value = AcquiredTextBox.Text
cmd.Parameters.Add("@date_of_purchase", OleDbType.VarChar).Value = Date_of_purchaseDateTimePicker.Value
cmd.Parameters.Add("@course", OleDbType.VarChar).Value = CourseTextBox.Text
cmd.Parameters.Add("@material", OleDbType.VarChar).Value = MaterialTextBox.Text
cmd.Parameters.Add(imgparam)
cmd.ExecuteNonQuery()
cmd.Dispose()
CN.Close()
CN.Dispose()
End If
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
|
|
|
|
|
Please do not repost the same question.
|
|
|
|
|
Hi! Can somebody help me. I am beginner. I have a project and need to update datagridview with image column, using Access databse. I have code for insert new row with image and as I understand it can be modified for updating row. I try to modify, but problem is not working. Now no any alarms or errors occurs, database not changed.
Many thanks un advance.
Private Sub Btn_Save_Click(sender As Object, e As EventArgs) Handles Btn_Update.Click
Try
If PhotoPictureBox.Image Is Nothing Then
If MsgBox("Are you sure you don't want to upload any pictures?", MsgBoxStyle.Information + MsgBoxStyle.YesNo, "Missing picture") Then
Dim CN As New OleDbConnection(connection)
CN.Open()
Dim Int As String
Int = "UPDATE Germany set [Year_of_release]=@year_of_release, [Denomination]=@denomination, [Governing_body]=@governing_body, [Acquired]=@acquired, [Date_of_purchase]=@date_of_purchase, [Course]=@course, [Material]=@material WHERE [ID]=@ID"
Dim cmd As New OleDbCommand(Int, CN)
'cmd.Parameters.Add("@ID", OleDbType.VarChar).Value = IDTextBox.Text
cmd.Parameters.Add("@year_of_release", OleDbType.VarChar).Value = Year_of_releaseDateTimePicker.Value
cmd.Parameters.Add("@denomination", OleDbType.VarChar).Value = DenominationTextBox.Text
cmd.Parameters.Add("@governing_body", OleDbType.VarChar).Value = Governing_bodyTextBox.Text
cmd.Parameters.Add("@acquired", OleDbType.VarChar).Value = AcquiredTextBox.Text
cmd.Parameters.Add("@date_of_purchase", OleDbType.VarChar).Value = Date_of_purchaseDateTimePicker.Value
cmd.Parameters.Add("@course", OleDbType.VarChar).Value = CourseTextBox.Text
cmd.Parameters.Add("@material", OleDbType.VarChar).Value = MaterialTextBox.Text
cmd.ExecuteNonQuery()
cmd.Dispose()
CN.Close()
CN.Dispose()
End If
Else
If imgName <> "" Then
Dim fs As FileStream
fs = New FileStream(imgName, FileMode.Open, FileAccess.Read)
Dim picturebytes As Byte() = New Byte(fs.Length - 1) {}
fs.Read(picturebytes, 0, System.Convert.ToInt32(fs.Length))
fs.Close()
Dim CN As New OleDbConnection(connection)
CN.Open()
Dim Int As String
Int = "UPDATE Germany set [Year_of_release]=@year_of_release, [Denomination]=@denomination, [Governing_body]=@governing_body, [Acquired]=@acquired, [Date_of_purchase]=@date_of_purchase, [Course]=@course, [Material]=@material, [Photo]=@photo WHERE [ID]=@ID"
Dim imgparam As New OleDbParameter()
imgparam.OleDbType = OleDbType.Binary
imgparam.ParameterName = "@photo"
imgparam.Value = picturebytes
Dim cmd As New OleDbCommand(Int, CN)
cmd.Parameters.Clear()
cmd.Parameters.Add("@ID", OleDbType.VarChar).Value = IDTextBox.Text
cmd.Parameters.Add("@year_of_release", OleDbType.VarChar).Value = Year_of_releaseDateTimePicker.Value
cmd.Parameters.Add("@denomination", OleDbType.VarChar).Value = DenominationTextBox.Text
cmd.Parameters.Add("@governing_body", OleDbType.VarChar).Value = Governing_bodyTextBox.Text
cmd.Parameters.Add("@acquired", OleDbType.VarChar).Value = AcquiredTextBox.Text
cmd.Parameters.Add("@date_of_purchase", OleDbType.VarChar).Value = Date_of_purchaseDateTimePicker.Value
cmd.Parameters.Add("@course", OleDbType.VarChar).Value = CourseTextBox.Text
cmd.Parameters.Add("@material", OleDbType.VarChar).Value = MaterialTextBox.Text
cmd.Parameters.Add(imgparam)
cmd.ExecuteNonQuery()
cmd.Dispose()
CN.Close()
CN.Dispose()
End If
End If
Catch ex As Exception
MsgBox(ex.Message.ToString)
End Try
End Sub
|
|
|
|
|
If you're not getting any errors, but your database is not being modified, then either there is no record in your database with the specified ID , or you're updating the wrong database.
One common problem is having a copy of your Access database as part of your project, and setting it to copy that file to the output directory. This will overwrite any changes you have made whilst your application was running.
You need to debug your code - in particular, check the value returned from the ExecuteNonQuery method, which will tell you the number of rows which were affected. In this case, it should return 1 - anything else indicates a problem with your data or your @ID parameter.
Quote:
Dim fs As FileStream
fs = New FileStream(imgName, FileMode.Open, FileAccess.Read)
Dim picturebytes As Byte() = New Byte(fs.Length - 1) {}
fs.Read(picturebytes, 0, System.Convert.ToInt32(fs.Length))
fs.Close() You can simplify that block to a single line:
Dim picturebytes As Byte() = File.ReadAllBytes(imgName)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hi
Again I found info that uses an xml file to makes controls.
TaskbarItemInfo Class (System.Windows.Shell) | Microsoft Docs
However where do i put these files? How do I create them? add > file > xml and change the text. I can do that but how to completly implement those files?
I'm working with default windows vb.net applications
Jan
|
|
|
|
|
That is XAML code, which is used to create the visual parts of WPF applications.
|
|
|
|
|
If by "default", you mean a Windows Forms application, the code you found will not work. That is XAML code, which is used in WPF applications and controls.
|
|
|
|
|
Yes I did mean Windows Form Application
So When I see code like that I can create controls like described in de xaml and take over the code and adapt where needed?
Any advances for windows forms over wpf? in any direction? Found already this Difference between WPF and WinForms - GeeksforGeeks
Jan
|
|
|
|
|
As we have said, this is XAML code and will only work with WPF applications.
|
|
|
|
|
You cannot adapt that code to work in Windows Forms, at all.
If there any benefit to using Windows Forms over WPF? Sure, the learning curve for Windows Forms is much easier compared to WPF. The advantage WPF has over Windows Forms is incredible power to create a UI over what is possible in Windows Forms.
|
|
|
|
|
|
how to make .OBJ 3D model viewer for vb.net 2010
|
|
|
|
|
Get this: GitHub - 5everin/3D-Model-Viewer: A software renderer written in vb.net[^] ... and see if it won't open without an error usg VS2010 (as you suggest) ... but regardless of whether it loads or not, dissecting the classes just to have a look at how something apparently more modern in it's approach to .obj manipulation and viewing could prove informative enough for you to have a go at it yourself ... starting with a VS2010 project, scratchwise.
|
|
|
|
|
|
how to view obj with direct x 8 vb6
|
|
|
|
|
You might be better off choosing a development platform that's not extinct like the dodo bird.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|