Click here to Skip to main content
15,917,964 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: copying cells to another worksheet in next available cell per column Pin
David Rubin5-May-14 9:22
David Rubin5-May-14 9:22 
AnswerRe: copying cells to another worksheet in next available cell per column Pin
ZurdoDev5-May-14 9:29
professionalZurdoDev5-May-14 9:29 
GeneralRe: copying cells to another worksheet in next available cell per column Pin
David Rubin5-May-14 9:40
David Rubin5-May-14 9:40 
AnswerRe: copying cells to another worksheet in next available cell per column Pin
ZurdoDev5-May-14 9:43
professionalZurdoDev5-May-14 9:43 
GeneralRe: copying cells to another worksheet in next available cell per column Pin
David Rubin5-May-14 9:48
David Rubin5-May-14 9:48 
GeneralRe: copying cells to another worksheet in next available cell per column Pin
ZurdoDev5-May-14 9:49
professionalZurdoDev5-May-14 9:49 
GeneralRe: copying cells to another worksheet in next available cell per column Pin
David Rubin5-May-14 12:27
David Rubin5-May-14 12:27 
AnswerRe: copying cells to another worksheet in next available cell per column Pin
ZurdoDev5-May-14 12:58
professionalZurdoDev5-May-14 12:58 
QuestionMicrosoft.Visualbasic Pin
SPSandy5-May-14 4:57
SPSandy5-May-14 4:57 
AnswerRe: Microsoft.Visualbasic Pin
Dave Kreskowiak5-May-14 6:20
mveDave Kreskowiak5-May-14 6:20 
GeneralRe: Microsoft.Visualbasic Pin
SPSandy5-May-14 9:55
SPSandy5-May-14 9:55 
QuestionE-mail Notification Pin
waner michaud4-May-14 13:23
waner michaud4-May-14 13:23 
AnswerRe: E-mail Notification Pin
Dave Kreskowiak4-May-14 18:37
mveDave Kreskowiak4-May-14 18:37 
QuestionCapture a monochrome image of panel control Pin
gwittlock3-May-14 2:27
gwittlock3-May-14 2:27 
AnswerRe: Capture a monochrome image of panel control Pin
Richard MacCutchan3-May-14 3:32
mveRichard MacCutchan3-May-14 3:32 
GeneralRe: Capture a monochrome image of panel control Pin
gwittlock3-May-14 3:41
gwittlock3-May-14 3:41 
GeneralRe: Capture a monochrome image of panel control Pin
Richard MacCutchan3-May-14 3:50
mveRichard MacCutchan3-May-14 3:50 
GeneralRe: Capture a monochrome image of panel control Pin
gwittlock3-May-14 5:09
gwittlock3-May-14 5:09 
GeneralRe: Capture a monochrome image of panel control Pin
Eddy Vluggen3-May-14 7:41
professionalEddy Vluggen3-May-14 7:41 
GeneralRe: Capture a monochrome image of panel control Pin
gwittlock3-May-14 7:53
gwittlock3-May-14 7:53 
Questionsimple multi thread app behaving weirdly Pin
Tony Snowden1-May-14 23:55
Tony Snowden1-May-14 23:55 
AnswerRe: simple multi thread app behaving weirdly Pin
Dave Kreskowiak2-May-14 5:31
mveDave Kreskowiak2-May-14 5:31 
GeneralRe: simple multi thread app behaving weirdly Pin
Tony Snowden5-May-14 21:42
Tony Snowden5-May-14 21:42 
hi dave... I didn't know if posting the code straight up was the done thing.. thought I would see if anyone would take a look first.

thanks & heres the code -

VB
Imports System.IO
Imports System.Threading

Public Class Form1

    Dim i1 As Integer
    Dim i2 As Integer


    Private Sub count1()

        Do While i1 < 3000
            i1 += 1
            If Me.Label1.InvokeRequired Then
                Me.Label1.Invoke(New Action(Sub() Me.Label1.Text = i1))
                Me.Label1.Invoke(New Action(Sub() Me.Refresh()))
            Else
                Me.Label1.Text = i1
                Me.Refresh()
            End If
        Loop

    End Sub


    Private Sub count2()

        Do While i2 < 3000
            i2 += 1
            If Me.Label2.InvokeRequired Then
                Me.Label2.Invoke(New Action(Sub() Me.Label2.Text = i2))
                Me.Label2.Invoke(New Action(Sub() Me.Refresh()))
            Else
                Me.Label2.Text = i2
                Me.Refresh()
            End If
        Loop

    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        i1 = 0
        Dim t As New Thread(AddressOf count1)
        t.Start()

    End Sub


    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        i2 = 0
        Dim t2 As New Thread(AddressOf count2)
        t2.Start()

    End Sub


End Class





@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

EDIT -

Hi Dave.. After looking at some explanations of using delegates and invoke I have changed my code as follows.. Still doesn't work like I would expect! Frown | :(

VB
Imports System.IO
Imports System.Threading

Public Class Form1

    Dim i1 As Integer
    Dim i2 As Integer


    Private Delegate Sub SetCount1()
    Private Delegate Sub SetCount2()


    Private Sub count1()

        Do While i1 < 100000
            i1 += 1
            updatecount1()
        Loop

    End Sub


    Private Sub count2()

        Do While i2 < 100000
            i2 += 1
            updatecount2()
        Loop

    End Sub


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        i1 = 0
        Dim t As New Thread(AddressOf count1)
        t.Start()

    End Sub


    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        i2 = 0
        Dim t2 As New Thread(AddressOf count2)
        t2.Start()

    End Sub


    Private Sub updatecount1()

        If Me.Label1.InvokeRequired Then
            Me.Label1.Invoke(New SetCount1(AddressOf updatecount1))
        Else
            Me.Label1.Text = i1
            Me.Refresh()
        End If


    End Sub


    Private Sub updatecount2()

        If Me.Label2.InvokeRequired Then
            Me.Label2.Invoke(New SetCount2(AddressOf updatecount2))
        Else
            Me.Label2.Text = i2
            Me.Refresh()
        End If

    End Sub

End Class


modified 6-May-14 9:57am.

GeneralRe: simple multi thread app behaving weirdly Pin
Dave Kreskowiak6-May-14 4:01
mveDave Kreskowiak6-May-14 4:01 
GeneralRe: simple multi thread app behaving weirdly Pin
Tony Snowden6-May-14 4:31
Tony Snowden6-May-14 4:31 

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.