Ik had laatst een vrij simpel programma'tje voor mezelf nodig dat groepen met subgroepen had, waar je vervolgens winst-objecten in kon plaatsen. Zoiets dus;
Hoofd groep: Schatten Zoeken
->Sub Groep: 1
->->Start Tijd
->->Eind Tijd
->->Winst Objecten:
->->->Naam: Goude ketting
->->->Waarde: 30,6
->->->Naam: 3 oude munten
->->->Waarde: 10,7
->->->etc.
En zo dus gemakkelijk uitrekenen wat je gemiddeld bij het 'schatten zoeken' verdient. Per uur, minuut, seconde, whatever.
Dus ik denk 'no way dat ik dat in C++ ga doen, ik doe dat even snel in vb.net'
Nou, als ik 'even snel' iets doe, dan krijg je dus dit (Code voor het toevoegen van een winst object aan een subgroep):
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'New ProfitObject
ReDim Preserve Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects.Length)
Dim ProfitObjectID As Integer = Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects.Length - 2
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID) = New ProfitObject
'Set ProfitObject properties
'Set ID
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).id = ProfitObjectID
'Set Name
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).name = TextBox1.Text
'Set Profit
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).profit = TextBox2.Text
'Set TypeID
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).typeID = TextBox3.Text
'Set Rarity
Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).rarity = TextBox4.Text
'populate(Form1.main.Groups(groupID))
Dim textt As String = "ID" & ProfitObjectID.ToString
groupForm.NewProfitObjectsItem(textt, Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).name, Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).profit, Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).rarity, Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID).ProfitObjects(ProfitObjectID).typeID)
End Sub |
Daar gaan je ogen van bloeden toch!? Dat kan beter:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim groupObject As GroupObject = Form1.main.Groups(theMainGroupID).GroupObjects(theGroupID)
'New ProfitObject
ReDim Preserve groupObject.ProfitObjects(groupObject.ProfitObjects.Length)
Dim ProfitObjectID As Integer = groupObject.ProfitObjects.Length - 2
Dim profit As ProfitObject = New ProfitObject()
groupObject.ProfitObjects(ProfitObjectID) = profit
'Set ProfitObject properties
profit.id = ProfitObjectID
profit.name = TextBox1.Text
profit.profit = TextBox2.Text
profit.typeID = TextBox3.Text
profit.rarity = TextBox4.Text
Dim textt As String = "ID" & ProfitObjectID
groupForm.NewProfitObjectsItem(profit)
End Sub |
Snel en netjes kan ik blijkbaar niet combineren