Oppure

Loading
26/04/14 15:36
ju89
Eccomi qui di nuovo, sto impazzendo! Premetto che sto facendo un programma da autodidatta leggendo guide ed altro, però mi sono bloccato in un passaggio che sicuramente sarà una bella cavolata, ma a me sembra un masso! :D

Vi incollo il codice e poi ve lo spiego

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If sanzione.Text = "" Then
            Return
        ElseIf sanzione.Text >= 211 And sanzione.Text <= 2108 Then
            sanzione12.Text = (sanzione.Text / 105).ToString("##")
        ElseIf sanzione.Text >= 2108.01 And sanzione.Text <= 5270 Then
            sanzione24.Text = (sanzione.Text / 105).ToString("##")
        ElseIf sanzione.Text >= 5270.01 And sanzione.Text <= 99999.99 Then
            sanzione60.Text = (sanzione.Text / 105).ToString("##")
        End If
        If sanzione12.Text >= 12 And sanzione12.Text < 24 Then
            Label2.Text = 12
        Else : Label2.Text = sanzione12.Text

        End If
        If sanzione24.Text > 24 And sanzione24.Text < 60 Then
            Label2.Text = 24
        Else : Label2.Text = sanzione24.Text

        End If
        If sanzione60.Text > 60 Then
            Label2.Text = 60
        Else : Label2.Text = sanzione60.Text
        End If

    End Sub


Allora se inserisco un valore tra 211-2108 il risultato di (sanzione/105) me lo deve mettere nella textbox denominata sanzione12.text, se questo valore è maggiore di 12 allora deve scrivermi 12 sennò il risultato che esce nella sanzione12.text.
Stessa cosa vale per il valore inserito tra 2108.01 e 5270.00; il risultato di (sanzione/105) me lo deve mettere nella textbox denominata sanzione24.text e anche qui se il valore è maggiore di 24 allora deve scrivermi 24 sennò il risultato che esce nella sanzione24.text.
Stessa cosa vale per il valore tra 5270.01 e 99999.99 ma non mi dilungo a spiegare perchè tanto è uguale alle altre due.
Dove sbaglio?potete aiutarmi? Che tra l'altro qui non mi funziona il programma non mi fa nessun calcolo, solo se lascio :


    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If sanzione.Text = "" Then
            Return
        ElseIf sanzione.Text >= 211 And sanzione.Text <= 2108 Then
            sanzione12.Text = (sanzione.Text / 105).ToString("##")
        ElseIf sanzione.Text >= 2108.01 And sanzione.Text <= 5270 Then
            sanzione24.Text = (sanzione.Text / 105).ToString("##")
        ElseIf sanzione.Text >= 5270.01 And sanzione.Text <= 99999.99 Then
            sanzione60.Text = (sanzione.Text / 105).ToString("##")
        End If
        If sanzione12.Text >= 12 And sanzione12.Text < 24 Then
            Label2.Text = 12
        Else : Label2.Text = sanzione12.Text
    End Sub


allora così il programma mi funziona. 8-|
aaa
26/04/14 19:47
Ultimo
    Public Class Form1

    Const a As Byte = 1
    Const b As Byte = 2
    Const c As Byte = 3
    Private f As Double


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

        Try
            Dim nx As Double = CDbl(TextBox1.Text)
            Call Esegui(nx)
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information)
        End Try

    End Sub

    Private Sub Esegui(ByRef k As Double)
        Try
            Label1.Text = ""
            If k > 100 And k < 1001 Then
                f = a * b * k
            ElseIf k > 1000 Then
                f = k / (a * b)
                Label1.Text = " Diviso 2   "
            Else : Label1.Text = " La sgniacchera  " & f.ToString("##")
                f = a * c * k
                Label1.Text &= "  e  La sgniacchera 2  : " & f.ToString("##") : Exit Sub
            End If
            Label1.Text &= " Risultato  " & f.ToString()

        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Information)
        End Try
    End Sub

End Class


Guarda questo codice, è un piccolo esempio di utilizzo di pulsanti, variabili, textbox, label, funzioni, codice di
controllo, ed altro...


If ok Then GOTO Avanza else GOTO Inizia