als label.text = 29 moet het 1 zijn werkt niet :S visual basic 2010

Status
Niet open voor verdere reacties.

danrik

Gebruiker
Lid geworden
12 jan 2010
Berichten
270
Oke, ik heb hieronder mijn code, de bedoeling is dat het programma de bureaubladachtergrond veranderd. Dit gebeurd prima, tot en met bestand 28.jpg, meer bestanden zijn er niet. Dan heb ik geprobeerd dat er een veld terug moet springen naar 1 als er 28 staat. Alles is op te maken uit de code. Bij voorbaat dank, Rik

Code:
Public Class Form2
    Private Declare Auto Function SystemParametersInfo Lib "user32.dll" (ByVal uAction As Integer, ByVal uParam _
As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) As Integer

    <System.Runtime.InteropServices.DllImport("user32.dll")> Public Shared Function GetAsyncKeyState(ByVal vKey As Keys) As Short
    End Function

    Public Shared Sub SetWallpaper(ByVal Wallpaper As Object)
        Dim Background As System.Drawing.Image = Nothing
        If TypeOf Wallpaper Is String Then
            Background = System.Drawing.Image.FromFile(Wallpaper)
        ElseIf TypeOf Wallpaper Is Image Then
            Background = Wallpaper
        Else
            Exit Sub
        End If
        Dim Location As String = Environment.SystemDirectory & "\CurrentWallpaper.Bmp"
        Background.Save(Location, System.Drawing.Imaging.ImageFormat.Bmp)
        SystemParametersInfo(&H14, 0, Location, &H1 Or &H2)
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Timer1.Start()

    End Sub

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

    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Label1.Text = "00"
        Label2.Text = "00"
        Label3.Text = "0"
        FileNUM.Text = "1"
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text += 1
        If Label1.Text = "60" Then
            Label2.Text += 1
            Label1.Text = "00"
            If FileNUM.Text = "29" Then
                FileNUM.Text = "1"
            End If

            If Label6.Text = "29" Then
                Label6.Text = "1"
            End If
            Label4.Text = FileDIR.Text + FileNUM.Text + FileType.Text
            SetWallpaper(Label4.Text)
            Label6.Text = FileNUM.Text + 1
            Label7.Text = FileDIR.Text + Label6.Text + FileType.Text
            PIC_Preview.Image = Image.FromFile(Label7.Text)
        End If

        If Label2.Text = "40" Then
            Label3.Text += 1
            Label2.Text = "00"
            FileNUM.Text += 1
        End If

        If Label3.Text = "40" Then
            FileNUM.Text += 1
            Label3.Text = "00"
        End If

        If GetAsyncKeyState(Keys.F10) <> 0 Then
            SetWallpaper(Label5.Text)
            Form1.Show()
            Me.Close()
        ElseIf GetAsyncKeyState(Keys.F11) <> 0 Then
            FileNUM.Text = "1"
        ElseIf GetAsyncKeyState(Keys.F12) <> 0 Then
            FileNUM.Text += 1
        End If
    End Sub

    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
    End Sub
End Class
 
Probeer deze eens:

Je hebt een klein foutje gemaakt

[CPP]
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Label1.Text += 1
If Label1.Text = "60" Then
Label2.Text += 1
Label1.Text = "00"

If Integer.Parse(FileNUM.Text) > 28 Then
FileNUM.Text = "1"
End If

If Integer.Parse(Label6.Text) > 28 Then
Label6.Text = "1"
End If

Label4.Text = FileDIR.Text + FileNUM.Text + FileType.Text
SetWallpaper(Label4.Text)
Label6.Text = FileNUM.Text + 1

If Integer.Parse(FileNUM.Text) > 28 Then
FileNUM.Text = "1"
End If

If Integer.Parse(Label6.Text) > 28 Then
Label6.Text = "1"
End If

Label7.Text = FileDIR.Text + Label6.Text + FileType.Text
PIC_Preview.Image = Image.FromFile(Label7.Text)
End If
[/CPP]

Hopelijk werkt het :)

Mvg,
Matthiee' van MatthiWare!
 
Dit is veel makkelijker:

[CPP]Private i As Integer = 0
Private Sub Timer1_Tick() Handles Timer1.Tick
Dim files As String() = IO.Directory.GetFiles("C:\blabla", "*.jpg")
MsgBox(files(i)) ''//hier het commando van het veranderen van het bureaublad
If i + 1 <> files.Length Then i += 1 Else i = 0
End Sub[/CPP]
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan