|
Instead of saying "I can't make to work correctly" can you be more precise with what is happening?
|
|
|
|
|
I have a menu with categories and subcategories structured as follows:
N1
|___ N2
|___ N3
|___ N4
The routine walks each item in N1 and checks for subitems(N2). If there is, go through each item N2 and check for subitems(N3). If there is, go through each item N3 and check for sub items(N4).
I am trying to implement an function like when unpacking a file, where there is a progressbar that shows the total progress (main) and another progressbar that shows the progress of each file being extracted. When each file is extracted and your progressbar reaches 100%, fills X% of the main progressbar.
N4 fills the N3 PBar -> N3 fills the N2 Pbar and N2 fills the N1(main) Pbar.
For Each N2 As TreeNode In N1.Nodes
For Each N3 As TreeNode In N2.Nodes
For Each N4 As TreeNode In N3.Nodes
Picture example
I am having difficulty defining the logic with which these Pbar work together.
Was I clear?
Thankyou for your reply.
|
|
|
|
|
I'm trying to change listview image at runtime, with this code:
Sub update_available_room()
Try
lvroom.BeginUpdate()
For Each L As ListViewItem In lvroom.Items
Dim mycommand As MySqlCommand = conn.open.CreateCommand
Dim query1 = "SELECT room.*,roomtype.* FROM room, roomtype WHERE room.RoomType=roomtype.RoomType AND RoomNo='" & L.ImageKey & "'"
mycommand.CommandText = query1
Dim baca1 As MySqlDataReader = mycommand.ExecuteReader
If baca1.Read() Then
Dim NoKamar As String = baca1("RoomNo")
Dim str As String
If Len(NoKamar) = 1 Then
str = "00" & NoKamar
ElseIf Len(NoKamar) = 2 Then
str = "0" & NoKamar
Else
str = NoKamar
End If
If baca1("Available") = True And baca1("Status") = False Then
L.ImageList.Images.RemoveByKey(L.ImageKey)
Dim newbitmap As Bitmap = My.Resources.bulat_hijau
Dim g As Graphics
g = Graphics.FromImage(newbitmap)
g.DrawString(str, New Font("Arial", 65, FontStyle.Bold), New SolidBrush(Color.Yellow), New Point(85, 50))
g.DrawString("______________________", New Font("Arial", 65, FontStyle.Bold), New SolidBrush(Color.White), New Point(0, 80))
g.DrawString(baca1("Singkatan"), New Font("Arial", 65, FontStyle.Bold), New SolidBrush(Color.White), New Point(82, 170))
L.Text = "EMPTY"
L.Font = New Font("Arial", 12, FontStyle.Bold)
L.ImageList.Images.Add(NoKamar, newbitmap)
ElseIf baca1("Available") = False And baca1("Status") = False Then
L.ImageList.Images.RemoveByKey(L.ImageKey)
Dim newbitmap As Bitmap = My.Resources.bulat_purple
Dim g As Graphics
g = Graphics.FromImage(newbitmap)
g.DrawString(str, New Font("Arial", 65, FontStyle.Bold), New SolidBrush(Color.Yellow), New Point(85, 50))
g.DrawString("______________________", New Font("Arial", 65, FontStyle.Bold), New SolidBrush(Color.White), New Point(0, 80))
g.DrawString(baca1("Singkatan"), New Font("Arial", 65, FontStyle.Bold), New SolidBrush(Color.White), New Point(82, 170))
L.Text = "N/A"
L.Font = New Font("Arial", 12, FontStyle.Bold)
L.ImageList.Images.Add(NoKamar, newbitmap)
End If
End If
baca1.Close()
lvroom.Refresh()
Next
conn.close()
lvroom.EndUpdate()
Catch ex As Exception
MsgBox(ex.Message)
Finally
conn.close()
End Try
End Sub
but I am getting err:
Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
|
|
|
|
|
Where do you get the error?
|
|
|
|
|
You already posted it here[^].
We can't tell you why this error came up because we don't have the data that this code is working against. I've told you how to debug this yourself because you're the only one who's going to be able to do it.
And I've already told you about the pile of resource leaks you have in this code.
|
|
|
|
|
|
I'm having a small issue wrapping my head around why this isn't working.
I have a file in my project called CollectionClasses.vb - within the Solution Explorer it's located in ProjectBase\Utilities\CollectionClasses.vb. Within that file, I've got classes that do not have Namespaces attached to them , they look like this.
Public Class LinerTypesCollection
Inherits System.Collections.ObjectModel.ObservableCollection(Of String)
Public Sub New(ByVal IsMetric As Boolean)
End Sub
End Class
Now, I've got a file within my project called StartPanel.vb, it is located ProjectBase\UI\Fitting Panels\Start\StartPanel.vb that has a Partial Class that uses the class defined above
Namespace Base.Controls.Panels
Partial Public Class StartPanel
Public Sub New (ByVal bool as Boolean, Optional ByVal bool2 as Boolean = false)
cmbBox.ItemsSource = New LinerTypesCollection(False)
End Sub
End Class
End Namespace
I am also trying to utilize this LinerTypesCollection class in another part of my software within a Public Class, like so, but unfortunately, I'm stuck in a rut, possibly over something simple, as to trying to figure out why. While trying to use LinerTypesCollection within my second class, it just won't show up. This class is located in the following location ProjectBase\UI\Primatives\ConnectionOptions.vb
Namespace Base.Utilities
Public Class ConnectionOption
Public Sub New (ByVal IsMetric as Boolean)
cmbBox.ItemsSource = New LinerTypesCollection(False)
End Sub
End Class
End Namespace
I have tried to change the "Base.Utilities" to "Base.Controls.Panels" to match and no avail, any ideas?
Thanks!
|
|
|
|
|
In VB.NET, classes with no namespace reside in the default namespace for the project.
Since your project is called ProjectBase, that's probably what the default namespace is set to. But you'll need to check the project properties to be sure.
How to: Change the Namespace for an Application (Visual Basic)[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard,
Thanks for replying!
That was my one of my initial assumptions as well, however; I have tried to do the following with my second class..
Namespace Base.Utilities
Public Class ConnectionOption
Public Sub New (ByVal IsMetric as Boolean)
cmbBox.ItemsSource = New ProjectBase.LinerTypesCollection(False)
End Sub
End Class
End Namespace
I have confirmed that the Root Namespace of the Project matches the what I'm trying to use, but alas, no avail. Intellisense won't pick it up as visible and I can't build it.
|
|
|
|
|
Try looking at your project in the Object Browser[^] to see if you can track down the class.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard,
I feel like a moron, but I knew it was something simple. Looking in the Object Browser as you recommended, it became clear that the files I was looking at were NOT in the same project.
They bled together pretty well in the Solution Explorer.
Regardless, thank you for taking the time to reply to my messages!
|
|
|
|
|
How to convert this codes to C# from VB6:
Hide Copy Code
Call rs.Open("SELECT DISTINCT Reci FROM " & CStr(duzina), Conn, adOpenKeyset)
rs.Move getRandom(0, rs.RecordCount - 1)
rec = rs.Fields(0).Value
Set rs = Conn.Execute("SELECT DISTINCT Reci FROM " & CStr(Len(r)))
|
|
|
|
|
|
I am using Access database!!!
|
|
|
|
|
|
|
It's both sad and frightening that this comes up so much on coding forums when people post their SQL code. +1 for fighting the good fight. I see it so much I'm almost numb to it now.
|
|
|
|
|
You would open a connection, then a issue a command against that connection, and then retrieving the results.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
How to pick random word from database and shuffle it???
|
|
|
|
|
Repeating the question means I'll be repeating my answer.
Try it one step at a time; first write some code to connect and execute a query. Once that works, you can try to get a random value.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
I don't know to work with databases.
|
|
|
|
|
..then I suggest you learn very quickly, as it is part of the code you are converting.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Can you give me link for learning database ?
|
|
|
|
|
Google[^] has a list; but skip the ones that use a wizard to generate the code.
As is, the VB code you posted would load an entire table and then pick a random record from that list. It would have been more efficient to generate a random id and fetch a single record.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
How to convert Access Database to SQL Database ?
|
|
|
|