Click here to Skip to main content
15,886,026 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Select columns access database Pin
Member 128225738-Dec-16 3:36
Member 128225738-Dec-16 3:36 
GeneralRe: Select columns access database Pin
Richard MacCutchan8-Dec-16 3:52
mveRichard MacCutchan8-Dec-16 3:52 
GeneralRe: Select columns access database Pin
Member 128225738-Dec-16 6:28
Member 128225738-Dec-16 6:28 
GeneralRe: Select columns access database Pin
Richard MacCutchan8-Dec-16 6:44
mveRichard MacCutchan8-Dec-16 6:44 
QuestionProgressbar feedback (one fill another) Pin
SHCruz5-Dec-16 22:49
SHCruz5-Dec-16 22:49 
QuestionRe: Progressbar feedback (one fill another) Pin
CHill606-Dec-16 5:08
mveCHill606-Dec-16 5:08 
AnswerRe: Progressbar feedback (one fill another) Pin
SHCruz7-Dec-16 11:59
SHCruz7-Dec-16 11:59 
QuestionVB.net - Index was out of range. Must be non-negative and less than the size of the collection Listview Pin
Abung Salman2-Dec-16 16:46
Abung Salman2-Dec-16 16:46 
I'm trying to change listview image at runtime, with this code:
VB
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


C#
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

QuestionRe: VB.net - Index was out of range. Must be non-negative and less than the size of the collection Listview Pin
Richard MacCutchan2-Dec-16 22:04
mveRichard MacCutchan2-Dec-16 22:04 
AnswerDon't post your question in multiple forums Pin
Dave Kreskowiak3-Dec-16 3:26
mveDave Kreskowiak3-Dec-16 3:26 
AnswerRe: VB.net - Index was out of range. Must be non-negative and less than the size of the collection Listview Pin
Richard Deeming5-Dec-16 2:00
mveRichard Deeming5-Dec-16 2:00 
QuestionQuestion about Class Interaction Pin
hilli_micha1-Dec-16 10:32
hilli_micha1-Dec-16 10:32 
AnswerRe: Question about Class Interaction Pin
Richard Deeming1-Dec-16 11:00
mveRichard Deeming1-Dec-16 11:00 
GeneralRe: Question about Class Interaction Pin
hilli_micha1-Dec-16 11:10
hilli_micha1-Dec-16 11:10 
GeneralRe: Question about Class Interaction Pin
Richard Deeming1-Dec-16 11:18
mveRichard Deeming1-Dec-16 11:18 
GeneralRe: Question about Class Interaction Pin
hilli_micha2-Dec-16 18:38
hilli_micha2-Dec-16 18:38 
QuestionConvert VB to C# Pin
Pavlex429-Nov-16 7:00
Pavlex429-Nov-16 7:00 
AnswerRe: Convert VB to C# Pin
Wendelius29-Nov-16 7:25
mentorWendelius29-Nov-16 7:25 
GeneralRe: Convert VB to C# Pin
Pavlex429-Nov-16 8:05
Pavlex429-Nov-16 8:05 
GeneralRe: Convert VB to C# Pin
Wendelius29-Nov-16 8:22
mentorWendelius29-Nov-16 8:22 
SuggestionRe: Convert VB to C# Pin
Richard Deeming29-Nov-16 9:26
mveRichard Deeming29-Nov-16 9:26 
GeneralRe: Convert VB to C# Pin
Jon McKee2-Dec-16 17:02
professionalJon McKee2-Dec-16 17:02 
AnswerRe: Convert VB to C# Pin
Eddy Vluggen29-Nov-16 10:11
professionalEddy Vluggen29-Nov-16 10:11 
GeneralRe: Convert VB to C# Pin
Pavlex430-Nov-16 1:37
Pavlex430-Nov-16 1:37 
GeneralRe: Convert VB to C# Pin
Eddy Vluggen30-Nov-16 3:16
professionalEddy Vluggen30-Nov-16 3:16 

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.