Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Mar 2009
    Messaggi
    500

    Problema stranissimo VB.net

    Salve, sto sviluppano un programma..

    se faccio:

    codice:
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            'INIZIO CONTROLLI
            If TextBox1.Text = "" Then
                MessageBox.Show("Errore N. 1")
                Exit Sub
            End If
    
            If Not IsNumeric(TextBox1.Text) Then
                MessageBox.Show("Errore N. 2")
                Exit Sub
            End If
    
            If TextBox2.Text = "" Then
                MessageBox.Show("Errore N. 3")
                Exit Sub
            End If
    
            If Not IsNumeric(TextBox2.Text) Then
                MessageBox.Show("Errore N. 4")
                Exit Sub
            End If
    
            If TextBox3.Text = "" Then
                MessageBox.Show("Errore N. 5")
                Exit Sub
            End If
    
            If Not IsNumeric(TextBox3.Text) Then
                MessageBox.Show("Errore N. 6")
                Exit Sub
            End If
    
            id = TextBox1.Text
            offerta_max = TextBox2.Text
            tempo = TextBox3.Text
    
    
    
            'INIZIO ATTIVAZIONE
            WebBrowser1.Navigate("http://***.it/" & id)
    
    
            If prezzo_ora > offerta_max Then
                MessageBox.Show("Errore N. 7")
                Exit Sub
            End If
    
            'ATTIVO TIMER SE TUTTO CORRETTO
            Timer1.Enabled = True
    
    
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            Dim html As String
            Dim posizione As String
            Dim i As Integer
    
            'Prelevo HTML
            html = WebBrowser1.DocumentText
    
            'Cerco la posizione approssimata
            posizione = InStr(html, "<span id=""v4-26"" class=""")
    
            'Scansione precisa
            For i = posizione To html.Length
                If html.Substring(i, 4) = "EUR " Or html.Substring(i, 4) = "US $" Then
                    i += 4
                    For j = i To html.Length
                        If html.Substring(j, 1) = "<" Then
                            prezzo_ora = html.Substring(i, j - i)
                            Exit For
                        End If
                    Next
                    Exit For
                End If
            Next
        End Sub
    IN QUEL MODO FUNZIONA SE INVECE CREO UNA FUNZIONE AL POSTO BUTTON2 MI DICE:
    Index e length devono fare riferimento a una posizione nella stringa. Nome parametro: length
    sulla riga
    codice:
                If html.Substring(i, 4) = "EUR " Or html.Substring(i, 4) = "US $" Then
    Ho sbattuto troppo la testa ma non riesco a capire.. qualcuo che mi aiuta?

  2. #2
    Utente di HTML.it L'avatar di oregon
    Registrato dal
    Jul 2005
    residenza
    Roma
    Messaggi
    36,480
    Cioe'? Se usi una funzione ... quale funzione? Scritta come?

    Qual è il codice che non funziona ?
    No MP tecnici (non rispondo nemmeno!), usa il forum.

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.