|
|
|
There is no "complete" list; not every application registers an uninstaller with Windows.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
The SQL code am using is
Private Sub Command8_Click()
Dim SQL As String
SQL = "SELECT tblVisit.PatientID, tblPatients.Firstname, tblPatients.Lastname" _
& "DateDiff('yyyy',[tblPatients]![Birthday],Now()) AS Age, tblVisit.[Date Visit]" _
& "tblVisit.Diagnosis" _
& "[First Name] & ' ' & [Last Name] AS [Prescriber Names] FROM tblPatients INNER JOIN (tblDoctor INNER JOIN tblVisit ON tblDoctor.DoctorID = tblVisit.DoctorID) ON tblPatients.PatientID = tblVisit.PatientID" _
& "WHERE [Firstname] = '" & Me.txtKeywords & "' "
Me.subClientList.Form.RecordSource = SQL
Me.subClientList.Form.Requery
End Sub
The error that is coming up is..
The error is runtime error '3075'
syntax error (missing operator) in query expression 'tblvist'.[DateVisit]tblVist.Diagnosis[First Name]& ' ' [Last Name]'
The
[First Name]& ' ' [Last Name]' are from a table prescribers and the
tblVist.Diagnosis is an attachment column in the table visit and the
tblvist'.[DateVisit]tblVist is a column of visit dates
|
|
|
|
|
I think you need a comma after each item.
|
|
|
|
|
Thanks alot for your input. Because of you. I managed to troubleshoot and I have got it working. thanks alot
|
|
|
|
|
You're using string concatenation to build the query. This alone is a bad idea as you are very vulnerable to making mistakes and you open the database up to being destroyed due to SQL Injection attacks.
Your code looks like this:
SQL = "SELECT tblVisit.PatientID, tblPatients.Firstname, tblPatients.Lastname" _
& "DateDiff('yyyy',[tblPatients]![Birthday],Now()) AS Age, tblVisit.[Date Visit]" _
& "tblVisit.Diagnosis" _
& "[First Name] & ' ' & [Last Name] AS [Prescriber Names] FROM tblPatients INNER JOIN (tblDoctor INNER JOIN tblVisit ON tblDoctor.DoctorID = tblVisit.DoctorID) ON tblPatients.PatientID = tblVisit.PatientID" _
& "WHERE [Firstname] = '" & Me.txtKeywords & "' "
This results in a query string that looks like this. Examine this query statement closely and you're going to find lots of problems. You're missing spaces between words and messed up the concatenation in places.
SELECT tblVisit.PatientID, tblPatients.Firstname, tblPatients.LastnameDateDiff('yyyy',[tblPatients]![Birthday],Now()) AS Age, tblVisit.[Date Visit]tblVisit.Diagnosis[First Name] & ' ' & [Last Name] AS [Prescriber Names] FROM tblPatients INNER JOIN (tblDoctor INNER JOIN tblVisit ON tblDoctor.DoctorID = tblVisit.DoctorID) ON tblPatients.PatientID = tblVisit.PatientIDWHERE [Firstname] = 'SqlInjectionAttack' "
Now, Google for "SQL Injection Attack" to find out why what you did was so wrong, then Goggle for "VB.NET SQL parameterized queries" to find out what to do about it.
|
|
|
|
|
Public Class Form1
Dim attempt As Integer
Private Sub BtnLogIn_Click(sender As Object, e As EventArgs) Handles BtnLogIn.Click
If CBUser.Text = "Mineomyn" And TBPass.Text = "lemsilog" Then
MsgBox("Log in successful!", MsgBoxStyle.Information)
TBPass.Clear()
GBAddons.Enabled = True
GBPizza.Enabled = True
RichTextBox1.Enabled = True
BtnCalculate.Enabled = True
BtnCompleteOrder.Enabled = True
BtnClearOrder.Enabled = True
TBAmount.Enabled = True
TBChange.Enabled = True
TBTotal.Enabled = True
BtnChange.Enabled = True
ElseIf CBUser.Text = "Lemsilog" And TBPass.Text = "lemsilog" Then
MsgBox("Log in successful!", MsgBoxStyle.Information)
TBPass.Clear()
GBAddons.Enabled = True
GBPizza.Enabled = True
RichTextBox1.Enabled = True
BtnCalculate.Enabled = True
BtnCompleteOrder.Enabled = True
BtnClearOrder.Enabled = True
TBAmount.Enabled = True
TBChange.Enabled = True
TBTotal.Enabled = True
BtnChange.Enabled = True
ElseIf CBUser.Text = "Lemzipon" And TBPass.Text = "lemsilog" Then
MsgBox("Log in successful!", MsgBoxStyle.Information)
TBPass.Clear()
GBAddons.Enabled = True
GBPizza.Enabled = True
RichTextBox1.Enabled = True
BtnCalculate.Enabled = True
BtnCompleteOrder.Enabled = True
BtnClearOrder.Enabled = True
TBAmount.Enabled = True
TBChange.Enabled = True
TBTotal.Enabled = True
BtnChange.Enabled = True
Else attempt = attempt + 1
End If
If attempt = 1 Then
MsgBox("Incorrect user or pass. Attempts left: 2", MsgBoxStyle.Exclamation)
TBPass.Clear()
GBAddons.Enabled = False
GBPizza.Enabled = False
RichTextBox1.Enabled = False
ElseIf attempt = 2 Then
MsgBox("Incorrect user or pass. Attempts left: 1", MsgBoxStyle.Exclamation)
TBPass.Clear()
GBAddons.Enabled = False
GBPizza.Enabled = False
RichTextBox1.Enabled = False
ElseIf attempt = 3 Then
MsgBox("Incorrect user or pass. You have reached maximum attempts to log in. Try again later.", MsgBoxStyle.Critical)
TBPass.Clear()
GBAddons.Enabled = False
GBPizza.Enabled = False
RichTextBox1.Enabled = False
BtnLogIn.Enabled = False
End If
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
GBPizza.Enabled = False
GBAddons.Enabled = False
RichTextBox1.Enabled = False
BtnCalculate.Enabled = False
BtnCompleteOrder.Enabled = False
BtnClearOrder.Enabled = False
TBAmount.Enabled = False
TBChange.Enabled = False
TBTotal.Enabled = False
BtnChange.Enabled = False
End Sub
Private Sub calculate()
Dim cost As Double
Dim order As String
If Radsmall.Checked Then
cost = Radsmall.Tag
order = "18 inch"
ElseIf Radmedium.Checked Then
cost = Radmedium.Tag
order = "24 inch"
Else
cost = Radlarge.Tag
order = "28 inch"
End If
If CB15Coke.Checked Then cost += CB15Coke.Tag
If CB1Coke.Checked Then cost += CB1Coke.Tag
If CBCrust.Checked Then cost += CBCrust.Tag
If CBextracheese.Checked Then cost += CBextracheese.Tag
If CBmushroom.Checked Then cost += CBmushroom.Tag
If CBsingledrink.Checked Then cost += CBsingledrink.Tag
TBTotal.Text = cost
Dim display As String = "You order a " & order
If ComboPizza.Text = "Pepperoni" Then display += " pepperoni pizza"
If ComboPizza.Text = "4 Cheese" Then display += " 4 cheese pizza"
If ComboPizza.Text = "All meat" Then display += " all meat pizza"
If ComboPizza.Text = "Hawaiian" Then display += " hawaiian pizza"
If ComboPizza.Text = "Classic Italian" Then display += " classic italian pizza"
If ComboPizza.Text = "New York Style" Then display += " New York style pizza"
If ComboPizza.Text = "Pure Beef" Then display += " pure beef pizza"
If CB15Coke.Checked Then display += " with 1.5L Coke"
If CB1Coke.Checked Then display += " with 1L Coke"
If CBCrust.Checked Then display += " with tuff crust"
If CBextracheese.Checked Then display += " with extra cheese"
If CBmushroom.Checked Then display += " with mushroom"
If CBsingledrink.Checked Then display += " with single drink"
Me.RichTextBox1.Text = display
End Sub
Private Sub BtnCalculate_Click(sender As Object, e As EventArgs) Handles BtnCalculate.Click
calculate()
End Sub
Private Sub BtnCancelOrder_Click(sender As Object, e As EventArgs) Handles BtnClearOrder.Click
TBAmount.Clear()
TBChange.Clear()
TBTotal.Clear()
Radlarge.Checked = False
Radmedium.Checked = False
Radsmall.Checked = False
CB15Coke.Checked = False
CB1Coke.Checked = False
CBCrust.Checked = False
CBextracheese.Checked = False
CBmushroom.Checked = False
CBsingledrink.Checked = False
ComboPizza.Text = ""
Me.RichTextBox1.Clear()
End Sub
Private Sub BtnChange_Click(sender As Object, e As EventArgs) Handles BtnChange.Click
TBChange.Text = Val(TBTotal.Text - TBAmount.Text)
End Sub
Private Sub BtnCompleteOrder_Click(sender As Object, e As EventArgs) Handles BtnCompleteOrder.Click
MsgBox("Order is complete. Your order will be delivered to you within 45 minutes. Thank you!")
End Sub
End Class
The "Calculate Order" button will do the total order. Then I have to manually put the amount on the "Amount Paid" textbox to get the change. Now, what I wanted to do is to assign the enter key so that I can just press enter after typing the amount and don't have to hover the mouse and click the "Amount Paid" button. I don't know the codes for it, and where should i put the codes, on the textbox or on the button? The accept button property is already used on my "Log in" button. Please help me. xD Thanks in advance!
|
|
|
|
|
|
Hello !
Is there any fast way to create a list of obj1(Integer,string) , where the first field is an integer from 1-2000 , and the second field is the same string. , so the list should be : (1,"a") , (2,"a"),(3,"a")........(2000,"a").
I know that with a for loop can I create this , but i'm asking if there's a more fast way.
Thank you !
|
|
|
|
|
Depends what you mean by "fast".
If you mean you want to save on typing, then try LINQ:
Dim myList As List(Of obj1) = Enumerable.Range(1, 2000).Select(Function(i) New obj1(i, "a")).ToList()
If you want the code to execute faster, then a For loop is probably your best bet. If you know the size of the list, then make sure you specify the initial capacity, to avoid having to reallocate the internal storage over and over again.
List<T>.Capacity Property (System.Collections.Generic) | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
for loop is faster than Linq ?
In other occasions , the for loop was very slower than Linq
|
|
|
|
|
desanti wrote: In other occasions , the for loop was very slower than Linq Measured by you on a timer?
One is a simple loop, the other a call to an interface to return an object on each iteration. Which of the two do you think would be faster?
Also, instead of having a list, this would probably be done faster by casting the int to a string when you need it, instead of having it in memory in a non-array.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi,
Wonder if there's a better approach to fill a Treeview recursively. Following snippet fills the Treeview but if I need an extra level I'd have to create yet another Sub. There must be a way of doing it recursively? Also I'm not able to show CategoryName on every node (please see tree representations below):
IdCategory CategoryName ParentCategory
15 Uncategorized 0
50 Animals 0
51 Plants 0
52 Dogs 50
53 Small 52
54 Medium 52
55 Large 52
56 Trees 51
57 Flowers 51
58 White 55
59 Brown 55
I call FillRootLevel and get the following:
0
Animals
Plants
Uncategorized
50
Dogs
51
Flowers
Trees
52
Large
Medium
Small
55
Brown
White
Private Sub FillRootLevel()
tvCategories.Nodes.Clear()
dtCategories = obj.ListCategories().Tables("Data")
For Each dr As DataRow In dtCategories.Rows
Dim node As New TreeNode With {
.Text = dr("IdCategory"),
.Tag = dr("CategoryName")
}
tvCategories.Nodes.Add(node)
FillParentCategories(node.Tag, node)
Next
End Sub
Private Sub FillParentCategories(ByVal strNodeTag As String, ByVal parentnode As TreeNode)
dtParentCategories = obj.ListParentCompanies().Tables("Data")
For Each dr As DataRow In dtParentCategories.Rows
Dim node As New TreeNode With {
.Text = dr("ParentCategory"),
.Tag = dr("ParentCategory")
}
parentnode.Nodes.Add(node)
FillCategories(node.Tag, node)
Next
End Sub
Private Sub FillCategories(ByVal strParentCategory As String, ByVal parentnode As TreeNode)
dtCategories = obj.ListCategories(strParentCategory).Tables("Datos")
For Each dr As DataRow In dtCategories.Rows
Dim node As New TreeNode With {
.Text = dr("CategoryName"),
.Tag = dr("CategoryName")
}
parentnode.Nodes.Add(node)
Next
End Sub
I'd need:
Uncategorized
Animals
Dogs
Large
Brown
White
Medium
Small
Plants
Flowers
Trees
Searched quite a bit for a solution but couldn't find a VB.NET / C# acceptable one.
Thanks for any help you may provide!
Sergio
modified 7-Dec-18 18:33pm.
|
|
|
|
|
When you create a node, name it using the value of "IdCategory". When reading the next item, take parentId, and search the entire treeview for a node that has that name as its Id. (FindNode or similar would do, without having to use recursion).
If it exists, add the current item as a child to that node.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Something like below would work
Public Class Form1
Public Class Thingy
Sub New(id As Long, catName As String, parentId As Long)
IdCategory = id
CategoryName = catName
ParentCategory = parentId
End Sub
Public IdCategory As Long
Public CategoryName As String
Public ParentCategory As Long
End Class
Sub New()
InitializeComponent()
Dim data As List(Of Thingy) = New List(Of Thingy)
data.Add(New Thingy(15, "Uncategorized", 0))
data.Add(New Thingy(50, "Animals", 0))
data.Add(New Thingy(51, "Plants", 0))
data.Add(New Thingy(52, "Dogs", 50))
data.Add(New Thingy(53, "Small", 52))
data.Add(New Thingy(54, "Medium", 52))
data.Add(New Thingy(55, "Large", 52))
data.Add(New Thingy(56, "Trees", 51))
data.Add(New Thingy(57, "Flowers", 51))
data.Add(New Thingy(58, "White", 55))
data.Add(New Thingy(59, "Brown", 55))
Dim tv As New TreeView
tv.Dock = DockStyle.Fill
Me.Controls.Add(tv)
For Each item As Thingy In data
Dim possibleParent As TreeNode() = tv.Nodes.Find(item.ParentCategory, searchAllChildren:=True)
If possibleParent.Count = 0 Then
tv.Nodes.Add(key:=item.IdCategory, text:=item.CategoryName)
Else
possibleParent.First().Nodes.Add(key:=item.IdCategory, text:=item.CategoryName)
End If
Next
End Sub
End Class
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Thanks so much Eddy, looks a lot easier that I would ever thought of. Great answer.
Regards,
Sergio
|
|
|
|
|
Thank you for making me a bit happier, and you're welcome
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi Eddie,
Realized I need to add an extra level to the tree. Changed your code to add the ShopName to the list of Thingy. Did a For Each to add all shop names to the tree as a first stage (there's only a max of 10 anyway).
I then tried to first filter the tree by ShopName to then add the nodes according to your code, but I can't seem to figure it out. I think possibleParent tv.Nodes.Find is not taking into account my possibleShop tv.nodes.find ?
Would you have any suggestions on this one ?
Dank U Wel
Dim data As List(Of Thingy) = New List(Of Thingy) From {
New Thingy("SHOP 1", 15, "Uncategorized", 0),
New Thingy("SHOP 1", 50, "Animals", 0),
New Thingy("SHOP 1", 51, "Plants", 0),
New Thingy("SHOP 1", 52, "Dogs", 50),
New Thingy("SHOP 1", 53, "Small", 52),
New Thingy("SHOP 1", 54, "Medium", 52),
New Thingy("SHOP 1", 55, "Large", 52),
New Thingy("SHOP 1", 56, "Trees", 51),
New Thingy("SHOP 1", 57, "Flowers", 51),
New Thingy("SHOP 1", 58, "White", 55),
New Thingy("SHOP 1", 59, "Brown", 55),
New Thingy("SHOP 2", 15, "Uncategorized", 0),
New Thingy("SHOP 2", 50, "Animals", 0),
New Thingy("SHOP 2", 51, "Plants", 0),
New Thingy("SHOP 2", 52, "Dogs", 50),
New Thingy("SHOP 2", 53, "Small", 52),
New Thingy("SHOP 2", 54, "Medium", 52),
New Thingy("SHOP 2", 55, "Large", 52),
New Thingy("SHOP 2", 56, "Trees", 51),
New Thingy("SHOP 2", 57, "Flowers", 51),
New Thingy("SHOP 2", 58, "White", 55),
New Thingy("SHOP 2", 59, "Brown", 55)
}
For Each item As Thingy In data
Dim possibleShop As TreeNode() = tv.Nodes.Find(item.ShopName, searchAllChildren:=True)
If possibleShop.Count = 0 Then
tv.Nodes.Add(key:=item.ShopName, text:=item.ShopName)
End If
Next
For Each item As Thingy In data
Dim possibleShop As TreeNode() = tv.Nodes.Find(item.ShopName, searchAllChildren:=True)
If possibleShop.Count > 0 Then
Dim possibleParent As TreeNode() = tv.Nodes.Find(item.ParentCategory, searchAllChildren:=True)
If possibleParent.Count = 0 Then
tv.Nodes.Add(key:=item.IdCategory, text:=item.CategoryName)
Else
possibleParent.First().Nodes.Add(key:=item.IdCategory, text:=item.CategoryName)
End If
End If
Next
|
|
|
|
|
You could add a level without changing the code; all that needs changing is the data (assuming you are still reading it from a DB as a table, instead of a hard-coded list I'm using for explanation)
Dim data As List(Of Thingy) = New List(Of Thingy)
data.Add(New Thingy(1, "Shop 1", 0))
data.Add(New Thingy(2, "Shop 2", 0))
data.Add(New Thingy(11, "Uncategorized", 1))
data.Add(New Thingy(21, "Uncategorized", 2))
data.Add(New Thingy(12, "Animals", 1))
data.Add(New Thingy(22, "Animals", 2))
data.Add(New Thingy(13, "Plants", 1))
data.Add(New Thingy(23, "Plants", 2))
data.Add(New Thingy(222, "Dogs", 22))
data.Add(New Thingy(2221, "Small", 222))
data.Add(New Thingy(2222, "Medium", 222))
data.Add(New Thingy(2223, "Large", 222))
data.Add(New Thingy(131, "Trees", 13))
data.Add(New Thingy(132, "Flowers", 13))
data.Add(New Thingy(1321, "White", 132))
data.Add(New Thingy(1322, "Brown", 132))
data.Add(New Thingy(232, "Flowers", 23))
data.Add(New Thingy(2321, "White", 232))
data.Add(New Thingy(2322, "Brown", 232))
If you want to add another level, just give it a new number and decide who is going to be the parent-item.
For example, if the White flowers would be divided into thorny and non-thorny, we'd add numbers similar to below;
data.Add(New Thingy(23211, "Thorny", 2321))
data.Add(New Thingy(23212, "Non-thorny", 2321))
Graag gedaan
PS: you don't have to use the numbering-scheme like I did - as long as each item in the tree has a unique number, everything should work. So, numbering them 1,2,3,4,5 etc doesn't change it. Feel free to use a more friendly numbering
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hey Eddie,
You actually didn't add another level to the data. I have 4 elements:
New Thingy("SHOP 1", 55, "Large", 52)
We're pretty close with the code below but there must be something wrong with the statement after the only ELSE. I'm getting:
Shops
---Shop1
------Uncategorized
------Animals
------Plants
...
---Shop2
------Uncategorized
------Animals
------Plants
...
ie it
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim data As List(Of Thingy) = New List(Of Thingy) From {
New Thingy("SHOP 1", 15, "Uncategorized", 0),
New Thingy("SHOP 1", 50, "Animals", 0),
New Thingy("SHOP 1", 51, "Plants", 0),
New Thingy("SHOP 1", 52, "Dogs", 50),
New Thingy("SHOP 1", 53, "Small", 52),
New Thingy("SHOP 1", 54, "Medium", 52),
New Thingy("SHOP 1", 55, "Large", 52),
New Thingy("SHOP 1", 56, "Trees", 51),
New Thingy("SHOP 1", 57, "Flowers", 51),
New Thingy("SHOP 1", 58, "White", 55),
New Thingy("SHOP 1", 59, "Brown", 55),
New Thingy("SHOP 2", 15, "Uncategorized", 0),
New Thingy("SHOP 2", 50, "Animals", 0),
New Thingy("SHOP 2", 51, "Plants", 0),
New Thingy("SHOP 2", 52, "Dogs", 50),
New Thingy("SHOP 2", 53, "Small", 52),
New Thingy("SHOP 2", 54, "Medium", 52),
New Thingy("SHOP 2", 55, "Large", 52),
New Thingy("SHOP 2", 56, "Trees", 51),
New Thingy("SHOP 2", 57, "Flowers", 51),
New Thingy("SHOP 2", 58, "White", 55),
New Thingy("SHOP 2", 59, "Brown", 55)
}
tv.Nodes.Add("Shops", "Shops")
For Each item As Thingy In data
Dim possibleRoot As TreeNode() = tv.Nodes.Find(item.ShopName, searchAllChildren:=True)
If possibleRoot.Count = 0 Then
tv.Nodes(0).Nodes.Add(key:=item.ShopName, text:=item.ShopName)
End If
Next
For Each item As Thingy In data
Dim possibleParent As TreeNode() = tv.Nodes.Find(item.ShopName, searchAllChildren:=True)
If possibleParent.Count = 0 Then
tv.Nodes.Add(key:=item.IdCategory, text:=item.CategoryName)
Else
possibleParent.First().Nodes.Add(key:=item.IdCategory, text:=item.CategoryName)
End If
Next
tv.ExpandAll()
End Sub
And the class is now:
Public Class Thingy
Sub New(ShpName As String, id As Long, catName As String, parentId As Long)
ShopName = ShpName
IdCategory = id
CategoryName = catName
ParentCategory = parentId
End Sub
Public Property ShopName As String
Public Property IdCategory As Long
Public Property CategoryName As String
Public Property ParentCategory As Long
End Class
Ik zit vast met deze boom. Heel erg bedankt voor al je hulp
Sergio
|
|
|
|
|
sterenas wrote: You actually didn't add another level to the data. AFAIK, I did; using the same code, we can also easily add the rootlevel called "shops", if you want the tree to start there. Simply take the code with the changes I proposed, and add the code below;
Dim data As List(Of Thingy) = New List(Of Thingy)
data.Add(New Thingy(99999, "Shops", 0))
data.Add(New Thingy(1, "Shop 1", 99999))
data.Add(New Thingy(2, "Shop 2", 99999))
The tree will then have a single branch called shops, with a list of shops under that node, and categories of stuff to sell within that. I used a higher number for the lowest level to show that the numbers are only used to "link" the nodes together - the number in itself is meaningless.
sterenas wrote: Public Class Thingy I've used the thingy-class as a placeholder for the data; they're just nodes. When adding a level, all we need is three things:
* the Id of the node (what the treenode is called)
* the Id of the node that we're going display this one in (the parent node)
* a name to display (which does not have to be limited to categories)
If any node is clicked, you can traverse the tree to see which shop it belongs to.
sterenas wrote: About to give up on this treeview and use a datagridview which is far simpler to understand The choice between TreeView and GridView is determined by the data; if it is a tree, you use a tree, if it is a grid, you use the gridview. We don't do grids in trees or trees in grids, because that becomes complicated quickly.
Complicated code is frustrating, which leads to anger, which leads to the dark side.
sterenas wrote: Ik zit vast met deze boom. Heel erg bedankt voor al je hulp No problem, we all been stuck at some point
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Great explanation Eddie, you nailed it! Enclosing the working code just in case someone else is as stuck as I was. You only need to add a treeview named tv to Form1.
Again thanks so much for your time and help and Heb een geweldige dag in zo'n mooi land.
Sergio
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim data As List(Of Thingy) = New List(Of Thingy) From {
New Thingy(99999, "Shops", 0),
New Thingy(1, "Shop 1", 99999),
New Thingy(2, "Shop 2", 99999),
New Thingy(15, "Uncategorized", 1),
New Thingy(15, "Uncategorized", 2),
New Thingy(50, "Animals", 1),
New Thingy(51, "Plants", 1),
New Thingy(52, "Dogs", 50),
New Thingy(53, "Small", 52),
New Thingy(54, "Medium", 52),
New Thingy(55, "Large", 52),
New Thingy(56, "Trees", 51),
New Thingy(57, "Flowers", 51),
New Thingy(58, "White", 55),
New Thingy(59, "Brown", 55)
}
For Each item As Thingy In data
Dim possibleParent As TreeNode() = tv.Nodes.Find(item.ParentCategory, searchAllChildren:=True)
If possibleParent.Count = 0 Then
tv.Nodes.Add(key:=item.IdCategory, text:=item.CategoryName)
Else
possibleParent.First().Nodes.Add(key:=item.IdCategory, text:=item.CategoryName)
End If
Next
tv.ExpandAll()
End Sub
End Class
Public Class Thingy
Sub New(id As Long, catName As String, parentId As Long)
IdCategory = id
CategoryName = catName
ParentCategory = parentId
End Sub
Public IdCategory As Long
Public CategoryName As String
Public ParentCategory As Long
End Class
|
|
|
|
|
Thanks; btw, you might consider giving the thingy a better name
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello !
I'm using Entity Framework 6
I have Myobject1 : Name , City , Price, Value
I want to group all the items on groups that have the same Name , city and Price.
After I want to count the groups that have more than 1 item.
I'm using this code :
Dim q As Integer = context.myobjects.GroupBy(Function(x) New With {x.Name,x.City,x.Price}).Where(Function(t3) t3.Count > 1).Count
But this query always return 0
But on my table I have several groups that have more than 1 item.
What is wrong with my query ?
Thank you !
|
|
|
|
|