본문 바로가기
VB.net

롤링 ListBox

by 호야호잇 2018. 4. 16.

Private Sub 롤링실행버튼_Click(sender As Object, e As EventArgs) Handles 롤링실행버튼.Click



        CheckForIllegalCrossThreadCalls = False  '쓰레드 오류 무시(정상적으로 사용하려면 delegate와 Invoke 사용 필요)

        Me.BackgroundWorker1.RunWorkerAsync()




    End Sub


Public Sub Delay(ByVal Second As Integer)


        Dim _startsecond As Integer


        _startsecond = Environment.TickCount


        While (True)


            If (Environment.TickCount - _startsecond >= Second * 1000) Then


                Exit While


            End If


            Application.DoEvents()


        End While


    End Sub



    Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork


        Try


'======================== DB 연결 ================================

            Dim DBConn As SqlConnection

            DBConn = New SqlConnection(dbstring_psnm)

            DBConn.Open()

            Dim mySqlCommAND As SqlCommand

            Dim QueryString As String

            QueryString = "select 유형1 From TB_Psnm_SMS_List ORDER BY 유형1 ASC "

            mySqlCommAND = New SqlCommand(QueryString, DBConn)

            Dim DBread As SqlDataReader = mySqlCommAND.ExecuteReader()


            While (DBread.Read())

                ListBox1.Items.Add(DBread.Item(0))

            End While


            DBread.Close()

            mySqlCommAND.Dispose()

            DBConn.Close()

'================================================================


            Delay(1)


'=========================== 롤링 쓰레드=============================

            Do Until DataGridView1.Location.Y = -120

                ListBox1.Location = New Point(3, ListBox1.Location.Y - 1)

                Threading.Thread.Sleep(50)

                Delay(0.5)

                Refresh()


            Loop

'================================================================


        Catch ex As Exception

            MessageBox.Show(ex.Message)

        End Try


    End Sub

'VB.net' 카테고리의 다른 글

레지스트리 하위키 값 검색  (0) 2018.04.27
C# > VB.NET 변환기  (0) 2018.04.24
숫자 올림, 반올림, 버림  (0) 2018.04.11
이미지 파일 첨부하여 Reszie하기(feat. 파일크기 제한)  (0) 2018.04.02
Form 확대/축소  (0) 2018.03.30