Click here to Skip to main content
15,910,787 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionSchema.Add returns Illegal characters in path. Pin
c_crookston3-Feb-10 6:16
c_crookston3-Feb-10 6:16 
AnswerRe: Schema.Add returns Illegal characters in path. Pin
c_crookston3-Feb-10 6:29
c_crookston3-Feb-10 6:29 
QuestionCan not set the name property of a timer at runtime - VB.NET Pin
castingflame3-Feb-10 2:07
castingflame3-Feb-10 2:07 
AnswerRe: Can not set the name property of a timer at runtime - VB.NET Pin
Covean3-Feb-10 2:34
Covean3-Feb-10 2:34 
AnswerRe: Can not set the name property of a timer at runtime - VB.NET Pin
Luc Pattyn3-Feb-10 2:34
sitebuilderLuc Pattyn3-Feb-10 2:34 
AnswerRe: Can not set the name property of a timer at runtime - VB.NET Pin
DaveAuld3-Feb-10 2:36
professionalDaveAuld3-Feb-10 2:36 
AnswerRe: Can not set the name property of a timer at runtime - VB.NET Pin
dan!sh 3-Feb-10 2:42
professional dan!sh 3-Feb-10 2:42 
AnswerRe: Can not set the name property of a timer at runtime - VB.NET Pin
Wayne Gaylard3-Feb-10 3:03
professionalWayne Gaylard3-Feb-10 3:03 
Hi Paul
If I am getting you correctly, you need to start a specific timer when it's corresponding button is clicked. To be honest I never followed your code, but I would do something like this

Public Class Form1

    Private lstButtons As New List(Of Button)
    Private lstTimers As New List(Of Timer)
    'create array of integers for timer intervals
    Private arrIntegers() As Integer = {25, 46, 91, 38, 50}

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        For i As Integer = 0 To 4
            Dim newButton As New Button
            newButton.Name = i
            newButton.Text = "Button " & i
            newButton.Width = 75
            newButton.Height = 25
            newButton.Left = 10
            newButton.Top = 10 + (25 * i) + (5 * i)
            newButton.Parent = Me
            newButton.Visible = True
            AddHandler newButton.Click, AddressOf ButtonsClick
            lstButtons.Add(newButton)
            Dim newTimer As New Timer
            newTimer.Interval = arrIntegers(i)
            AddHandler newTimer.Tick, AddressOf TimersTick
            lstTimers.Add(newTimer)
        Next

    End Sub

    Private Sub ButtonsClick(ByVal sender As Object, ByVal e As System.EventArgs)

        Dim intIndex As Integer = CInt(CType(sender, Button).Name)
        lstTimers(intIndex).Start()

    End Sub

    Private Sub TimersTick(ByVal sender As Object, ByVal e As System.EventArgs)

        CType(sender, Timer).Stop()
        MsgBox(CType(sender, Timer).ToString)

    End Sub

End Class


I have used lists rather than arrays (personal preference), but the gist of it should be the same. Instead of giving the buttons a name in the form of a string, use a number, and then reference the timer using the button name as an index. Hope this helps
AnswerRe: Can not set the name property of a timer at runtime - VB.NET Pin
Dave Kreskowiak3-Feb-10 3:29
mveDave Kreskowiak3-Feb-10 3:29 
GeneralRe: Can not set the name property of a timer at runtime - VB.NET Pin
castingflame3-Feb-10 7:01
castingflame3-Feb-10 7:01 
GeneralRe: Can not set the name property of a timer at runtime - VB.NET Pin
Paul Roseby3-Feb-10 10:25
Paul Roseby3-Feb-10 10:25 
GeneralRe: Can not set the name property of a timer at runtime - VB.NET Pin
Paul Roseby3-Feb-10 10:28
Paul Roseby3-Feb-10 10:28 
QuestionListView: How to link columnheader into subitem Pin
jtpaa2-Feb-10 23:44
jtpaa2-Feb-10 23:44 
AnswerRe: ListView: How to link columnheader into subitem Pin
DaveAuld3-Feb-10 0:41
professionalDaveAuld3-Feb-10 0:41 
AnswerRe: ListView: How to link columnheader into subitem Pin
DaveAuld3-Feb-10 1:06
professionalDaveAuld3-Feb-10 1:06 
GeneralRe: ListView: How to link columnheader into subitem Pin
jtpaa3-Feb-10 1:29
jtpaa3-Feb-10 1:29 
AnswerRe: ListView: How to link columnheader into subitem Pin
DaveAuld3-Feb-10 2:31
professionalDaveAuld3-Feb-10 2:31 
GeneralRe: ListView: How to link columnheader into subitem Pin
jtpaa3-Feb-10 2:54
jtpaa3-Feb-10 2:54 
GeneralRe: ListView: How to link columnheader into subitem Pin
DaveAuld3-Feb-10 3:00
professionalDaveAuld3-Feb-10 3:00 
GeneralRe: ListView: How to link columnheader into subitem Pin
JR2124-Feb-10 1:00
JR2124-Feb-10 1:00 
QuestionVB SendKeys -Done- Pin
εїзεїзεїз2-Feb-10 23:18
εїзεїзεїз2-Feb-10 23:18 
AnswerRe: VB SendKeys Pin
DaveAuld3-Feb-10 0:35
professionalDaveAuld3-Feb-10 0:35 
GeneralRe: VB SendKeys Pin
εїзεїзεїз3-Feb-10 1:07
εїзεїзεїз3-Feb-10 1:07 
GeneralRe: VB SendKeys Pin
DaveAuld3-Feb-10 1:23
professionalDaveAuld3-Feb-10 1:23 
AnswerRe: VB SendKeys Pin
Luc Pattyn3-Feb-10 1:57
sitebuilderLuc Pattyn3-Feb-10 1:57 

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.