Oppure

Loading
30/05/09 11:08
ruggy94
Postato originariamente da AMIGOS:
grazie infinita ruggy

Figurati ;)

Comunque guardando il tuo codice ho visto una cosa del genere:
If...Then
...
Else
If...Then
...
End If
End If

Che si può tranquillamente semplificare in
If...Then
...
ElseIf...Then
...
End If

:k:
aaa
30/05/09 12:17
Postato originariamente da AMIGOS:
grazie cassin.simone

Di niente...prego!:asd:
31/05/09 15:43
AMIGOS
Grazie ruggy94....delle if :k:
ma mi kiedo come mai, se clicco su 3 bottoni in contmporanea....2 me li lascia in stop..
come dovrebbe... e l 'altro me lo fa lampeggiare.....cosi se ne cliccassi anke piu..
solita cosa... posto il codice:


Public Class Form1



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

        If Button1.Text = "Start" Then
            Button1.Text = "Stop"
            Timer1.Interval = NumericUpDown1.Value
            Timer1.Enabled = True
        Else
            If Button1.Text = "Stop" Then
                Button1.Text = "Start"
                Timer1.Enabled = False
            End If

            End If
    End Sub



 

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ToolStripLabel2.Text = Len(TextBox1.Text)
        SendKeys.Send((TextBox1.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        TextBox4.Text = ""
        TextBox5.Text = ""
        TextBox6.Text = ""
        TextBox7.Text = ""
        TextBox8.Text = ""
        TextBox9.Text = ""
        TextBox10.Text = ""
        TextBox11.Text = ""
        TextBox12.Text = ""
        TextBox13.Text = ""
        TextBox14.Text = ""
        TextBox15.Text = ""
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        If Button4.Text = "Start" Then
            Button4.Text = "Stop"
            Timer2.Interval = NumericUpDown1.Value
            Timer2.Enabled = True
        Else
            If Button4.Text = "Stop" Then
                Button4.Text = "Start"
                Timer2.Enabled = False
            End If

        End If
    End Sub

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
        SendKeys.Send((TextBox2.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub


    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        If Button9.Text = "Start" Then
            Button9.Text = "Stop"
            Timer3.Interval = NumericUpDown1.Value
            Timer3.Enabled = True
        Else
            If Button9.Text = "Stop" Then
                Button9.Text = "Start"
                Timer3.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button29_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button29.Click
        If Button29.Text = "Start" Then
            Button29.Text = "Stop"
            Timer11.Interval = NumericUpDown1.Value
            Timer11.Enabled = True
        Else
            If Button29.Text = "Stop" Then
                Button29.Text = "Start"
                Timer11.Enabled = False
            End If

        End If
    End Sub

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
        SendKeys.Send((TextBox3.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
        SendKeys.Send((TextBox4.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
        SendKeys.Send((TextBox5.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick
        SendKeys.Send((TextBox6.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer7_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer7.Tick
        SendKeys.Send((TextBox7.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer8_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer8.Tick
        SendKeys.Send((TextBox8.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer9_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer9.Tick
        SendKeys.Send((TextBox9.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer10_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer10.Tick
        SendKeys.Send((TextBox10.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer11_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer11.Tick
        SendKeys.Send((TextBox11.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer12_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer12.Tick
        SendKeys.Send((TextBox12.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer13_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer13.Tick
        SendKeys.Send((TextBox13.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer14_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer14.Tick
        SendKeys.Send((TextBox14.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Timer15_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer15.Tick
        SendKeys.Send((TextBox15.Text))
        SendKeys.Send(("{ENTER}"))
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        If Button7.Text = "Start" Then
            Button7.Text = "Stop"
            Timer4.Interval = NumericUpDown1.Value
            Timer4.Enabled = True
        Else
            If Button7.Text = "Stop" Then
                Button7.Text = "Start"
                Timer4.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        If Button13.Text = "Start" Then
            Button13.Text = "Stop"
            Timer5.Interval = NumericUpDown1.Value
            Timer5.Enabled = True
        Else
            If Button13.Text = "Stop" Then
                Button13.Text = "Start"
                Timer5.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        If Button11.Text = "Start" Then
            Button11.Text = "Stop"
            Timer6.Interval = NumericUpDown1.Value
            Timer6.Enabled = True
        Else
            If Button11.Text = "Stop" Then
                Button11.Text = "Start"
                Timer6.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
        If Button17.Text = "Start" Then
            Button17.Text = "Stop"
            Timer7.Interval = NumericUpDown1.Value
            Timer7.Enabled = True
        Else
            If Button17.Text = "Stop" Then
                Button17.Text = "Start"
                Timer7.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        If Button15.Text = "Start" Then
            Button15.Text = "Stop"
            Timer8.Interval = NumericUpDown1.Value
            Timer8.Enabled = True
        Else
            If Button15.Text = "Stop" Then
                Button15.Text = "Start"
                Timer8.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button33_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button33.Click
        If Button33.Text = "Start" Then
            Button33.Text = "Stop"
            Timer9.Interval = NumericUpDown1.Value
            Timer9.Enabled = True
        Else
            If Button33.Text = "Stop" Then
                Button33.Text = "Start"
                Timer9.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button31_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button31.Click
        If Button31.Text = "Start" Then
            Button31.Text = "Stop"
            Timer10.Interval = NumericUpDown1.Value
            Timer10.Enabled = True
        Else
            If Button31.Text = "Stop" Then
                Button31.Text = "Start"
                Timer10.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button27_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button27.Click
        If Button27.Text = "Start" Then
            Button27.Text = "Stop"
            Timer12.Interval = NumericUpDown1.Value
            Timer12.Enabled = True
        Else
            If Button27.Text = "Stop" Then
                Button27.Text = "Start"
                Timer12.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button25_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button25.Click
        If Button25.Text = "Start" Then
            Button25.Text = "Stop"
            Timer13.Interval = NumericUpDown1.Value
            Timer13.Enabled = True
        Else
            If Button25.Text = "Stop" Then
                Button25.Text = "Start"
                Timer13.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button23_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button23.Click
        If Button23.Text = "Start" Then
            Button23.Text = "Stop"
            Timer14.Interval = NumericUpDown1.Value
            Timer14.Enabled = True
        Else
            If Button23.Text = "Stop" Then
                Button23.Text = "Start"
                Timer14.Enabled = False
            End If

        End If
    End Sub

    Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click
        If Button21.Text = "Start" Then
            Button21.Text = "Stop"
            Timer15.Interval = NumericUpDown1.Value
            Timer15.Enabled = True
        Else
            If Button21.Text = "Stop" Then
                Button21.Text = "Start"
                Timer15.Enabled = False
            End If

        End If
    End Sub

    Private Sub Timer16_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs)
        ToolStripLabel2.Text = Len(TextBox1.Text)
    End Sub

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

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

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

    End Sub

    Private Sub ToolStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ToolStrip1.ItemClicked

    End Sub

    Private Sub Timer16_Tick_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer16.Tick
        ToolStripLabel2.Text = Len(TextBox1.Text)
        ToolStripLabel3.Text = Len(TextBox2.Text)
        ToolStripLabel4.Text = Len(TextBox3.Text)
        ToolStripLabel5.Text = Len(TextBox4.Text)
        ToolStripLabel6.Text = Len(TextBox5.Text)
        ToolStripLabel7.Text = Len(TextBox6.Text)
        ToolStripLabel8.Text = Len(TextBox7.Text)
        ToolStripLabel9.Text = Len(TextBox8.Text)
        ToolStripLabel10.Text = Len(TextBox9.Text)
        ToolStripLabel11.Text = Len(TextBox10.Text)
        ToolStripLabel12.Text = Len(TextBox11.Text)
        ToolStripLabel13.Text = Len(TextBox12.Text)
        ToolStripLabel14.Text = Len(TextBox13.Text)
        ToolStripLabel15.Text = Len(TextBox14.Text)
        ToolStripLabel16.Text = Len(TextBox15.Text)


    End Sub


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

    
        Timer1.Enabled = False
      
        Timer2.Enabled = False
       
        Timer3.Enabled = False
        
        Timer4.Enabled = False
       
        Timer5.Enabled = False
        
        Timer6.Enabled = False
        
        Timer7.Enabled = False
       
        Timer8.Enabled = False
        
        Timer9.Enabled = False
       
        Timer10.Enabled = False
       
        Timer11.Enabled = False
        
        Timer12.Enabled = False
        
        Timer13.Enabled = False
        
        Timer14.Enabled = False
        
        Timer15.Enabled = False

    End Sub

    Private Sub Button5_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        
        Timer1.Interval = NumericUpDown1.Value
        Timer1.Enabled = True
        Timer2.Interval = NumericUpDown1.Value
        Timer2.Enabled = True
        Timer3.Interval = NumericUpDown1.Value
        Timer3.Enabled = True
        Timer4.Interval = NumericUpDown1.Value
        Timer4.Enabled = True
        Timer5.Interval = NumericUpDown1.Value
        Timer5.Enabled = True
        Timer6.Interval = NumericUpDown1.Value
        Timer6.Enabled = True
        Timer7.Interval = NumericUpDown1.Value
        Timer7.Enabled = True
        Timer8.Interval = NumericUpDown1.Value
        Timer8.Enabled = True
        Timer9.Interval = NumericUpDown1.Value
        Timer9.Enabled = True
        Timer10.Interval = NumericUpDown1.Value
        Timer10.Enabled = True
        Timer11.Interval = NumericUpDown1.Value
        Timer11.Enabled = True
        Timer12.Interval = NumericUpDown1.Value
        Timer12.Enabled = True
        Timer13.Interval = NumericUpDown1.Value
        Timer13.Enabled = True
        Timer14.Interval = NumericUpDown1.Value
        Timer14.Enabled = True
        Timer15.Interval = NumericUpDown1.Value
        Timer15.Enabled = True
    End Sub

    Private Sub Button6_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        NumericUpDown1.Value = "50"
    End Sub

    Private Sub ToolStripLabel2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripLabel2.Click


    End Sub
End Class



I bottoni sono numerati a caso, perkè prima avevo sia bottoni per lo start sia per lo stop....e gli o cancellati per adattare la vostra funzione...
Ultima modifica effettuata da AMIGOS 31/05/09 15:57
aaa
31/05/09 16:03
AMIGOS
Volevo chiedervi un altro favore se posso.....

Io volevo adattare l'invio delle frasi ..con tasti F1 ad F12.... cosi da farne
12 con tasti di scelta rapida F1 F2 F3 fino ad F12, e 12 con tasto start e stop....
se nn possibile, allora sapere solo se era possibile adattare al posto dei buttoni i tasti F..
Ultima modifica effettuata da AMIGOS 31/05/09 16:09
aaa
31/05/09 16:29
Jeremy
Postato originariamente da AMIGOS:

Volevo chiedervi un altro favore se posso.....

Io volevo adattare l'invio delle frasi ..con tasti F1 ad F12.... cosi da farne
12 con tasti di scelta rapida F1 F2 F3 fino ad F12, e 12 con tasto start e stop....
se nn possibile, allora sapere solo se era possibile adattare al posto dei buttoni i tasti F..

Ma ti sei fumato qualcosa????:om:
Non era meglio se andavi al mare???:cheer:

Prendi fiato e spiegati un pò meglio!!!:rofl:

Senza offese ma se non si capisce bene il problema non ti si può aiutare.

Facci sapere...
Ciao
aaa
31/05/09 17:16
AMIGOS
Vorrei attivare i comandi che invio con i bottoni, con i tasti F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12

insomma invece che inviare coi bottoni vorrei inviare con i tasti sopra citati....

invece di cliccare su button1 per inviare
clicco su F1
e cosi per il resto F2 ecc.
Ultima modifica effettuata da AMIGOS 31/05/09 17:22
aaa
31/05/09 17:39
Jeremy
Postato originariamente da AMIGOS:

Vorrei attivare i comandi che invio con i bottoni, con i tasti F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12

insomma invece che inviare coi bottoni vorrei inviare con i tasti sopra citati....

invece di cliccare su button1 per inviare
clicco su F1
e cosi per il resto F2 ecc.


Ok ... adesso è chiaro.
Puoi gestire l'evento KeyUp del Form e fare un selectcase per capire quale tasto è stato premuto e puntare alla routine gestita attualmente dal button.

  Private Sub Form1_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyUp
        Select Case e.KeyCode
            Case Keys.F1
                Button1_Click()
            Case Keys.F2
                Button2_Click()
             etc.....
        End Select
End Sub 


Ti conviene però, cancellare la firma del metodo ButtonX_Click()...voglio dire:
invece di:
Private Sub Button21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button21.Click 

diventa:
Private Sub Button21_Click() Handles Button21.Click 



Facci sapere...
Ciao
Ultima modifica effettuata da Jeremy 31/05/09 17:43
aaa
31/05/09 18:01
Jeremy
Ciao
Volendo perderci un pò di tempo sopra, si potrebbe sistemare un pò quel codice che hai scritto.

Intento prova a ragionare su questo, se ti interessa mettiamo a posto il resto.

 Private Sub AperturaForm() Handles Me.Load
        For Each Control As Control In Me.Controls
            If TypeOf Control Is Button Then
                AddHandler Control.Click, AddressOf ButtonClick
                Control.Tag = New Timer With {.Interval = Int32.Parse(NumericUpDown1.Value.ToString), .Tag = Control.Name}
                AddHandler DirectCast(Control.Tag, Timer).Tick, AddressOf GestioneTimer
            End If
        Next
    End Sub
    Private Sub ButtonClick(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim bt As Button = DirectCast(sender, Button)
        Dim Tmr As Timer = DirectCast(bt.Tag, Timer)

        If bt Is Button3 Then
            For Each Control As Control In Me.Controls
                If TypeOf Control Is TextBox Then
                    Control.Text = String.Empty
                End If
            Next
            Return
        End If
        If bt.Text = "Start" Then
            bt.Text = "Stop"
            Tmr.Enabled = True
        ElseIf bt.Text = "Stop" Then
            bt.Text = "Start"
            Tmr.Enabled = False
        End If
    End Sub
    Private Sub GestioneTimer(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim Tmr As Timer = DirectCast(sender, Timer)
        Select Case Tmr.Tag.ToString
            Case "Button1"
                SendKeys.Send((TextBox1.Text))
                SendKeys.Send(("{ENTER}"))
            Case "Button2"
                etc....
            Case "Button3"
                etc....
            Case "Button4"
        End Select
    End Sub


Facci sapere...
Ciao
aaa