Avatar billede xabdullahx Nybegynder
05. oktober 2008 - 17:20 Der er 5 kommentarer og
1 løsning

Fejl i kode - Hjælp

hej.

Dette har virket før, men ved ikke hvad der er galt nu, (Har lavet om på rækkefølger af erklæringerne), men her kommer koden:

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

        Dim fil As New IO.DirectoryInfo("C:\test2\")
        Dim fswf As IO.FileInfo() = fil.GetFiles("*.swf")
        Dim inf As IO.FileInfo
        Dim temp As String
        Dim LineOfText As String
        Dim i As Integer

        Dim FILE_Name123 As String = "C:\test2\" & Label2.Text & ".game.php"
        Dim TextLine As String

        For Each inf In fswf
            temp = Len(inf.Name123)
            temp = temp - 4
            temp = Microsoft.VisualBasic.Left(inf.Name123, temp)
            Label2.Text = (temp)




            'MsgBox(FILE_Name123)
            If System.IO.File.Exists(FILE_Name123) = True Then

                Dim objReader As New System.IO.StreamReader(FILE_Name123)

                Do While objReader.Peek() <> -1
                    TextLine = TextLine & objReader.ReadLine() & ","
                Loop



            Else

                TextBox3.Text = TextBox3.Text & Name123

            End If

            Dim aryTextFile() As String


            LineOfText = TextBox1.Text

            aryTextFile = LineOfText.Split(",")

            For i = 0 To UBound(aryTextFile)
                MsgBox(aryTextFile(i))
            Next i

            Dim Name123 As String
            Dim Width123 As String
            Dim Height123 As String

            Name123 = aryTextFile(43)
            Name123 = Len(Name123)
            Name123 = Name123 - 10
            Name123 = Microsoft.VisualBasic.Mid(aryTextFile(43), 9, Name123)
            'MsgBox(Name123)

            Width123 = aryTextFile(53)
            Width123 = Len(Width123)
            Width123 = Width123 - 15
            Width123 = Microsoft.VisualBasic.Mid(aryTextFile(53), 14, Width123)
            'MsgBox(Width123)

            Height123 = aryTextFile(56)
            Height123 = Len(Height123)
            Height123 = Height123 - 16
            Height123 = Microsoft.VisualBasic.Mid(aryTextFile(56), 15, Height123)
            'MsgBox(Height123)

            TextBox1.Text = TextLine




            TextBox2.Text = TextBox2.Text & "INSERT INTO ava_games (Name123, description, url, catergory_id, published, image, Width123, Height123, filetype) VALUES('" & Name123 & "', '', 'http://www.arcadeskillz.com/games/" & Label2.Text & ".swf', '2', '1', 'http://www.arcadeskillz.com/games/" & Label2.Text & "1.gif', '" & Width123 & "', '" & Height123 & "', '1');" & vbNewLine

        Next inf
    End Sub
Avatar billede xabdullahx Nybegynder
05. oktober 2008 - 17:20 #1
Det sidste er ikke vigtigt, det med textbox2.text
Avatar billede arne_v Ekspert
05. oktober 2008 - 17:42 #2
Det er VB.NET ikke VB.

Hvilken fejl får du ?
Avatar billede xabdullahx Nybegynder
05. oktober 2008 - 17:44 #3
ok, nu har jeg løst det.
men her kommer så det andet problem, name, width og height, er altid den samme værdi, nemlig den første fils værdier, hvordan gør jeg at den tjekker name w og h i alle filerne?

Koden ser således ud nu:

        Dim temp As String
        Dim Name As String
        Dim Width As String
        Dim Height As String
        Dim TextLine As String


        Dim fil As New IO.DirectoryInfo("C:\test2\")
        Dim fswf As IO.FileInfo() = fil.GetFiles("*.swf")
        Dim inf As IO.FileInfo


        For Each inf In fswf
            temp = Len(inf.Name)
            temp = temp - 4
            temp = Microsoft.VisualBasic.Left(inf.Name, temp)
            Label2.Text = (temp)


            'MsgBox(FILE_Name)

            Dim FILE_Name As String = "C:\test2\" & Label2.Text & ".game.php"
            If System.IO.File.Exists(FILE_Name) = True Then

                Dim objReader As New System.IO.StreamReader(FILE_Name)

                Do While objReader.Peek() <> -1
                    TextLine = TextLine & objReader.ReadLine() & ","

                Loop
                TextBox1.Text = TextLine
            Else

                TextBox3.Text = TextBox3.Text & Name

            End If

            Dim aryTextFile() As String
            Dim LineOfText As String
            Dim i As Integer

            LineOfText = TextBox1.Text

            aryTextFile = LineOfText.Split(",")

            For i = 0 To UBound(aryTextFile)
                'MsgBox(aryTextFile(i))
            Next i


            Name = aryTextFile(43)
            Name = Len(Name)
            Name = Name - 10
            Name = Microsoft.VisualBasic.Mid(aryTextFile(43), 9, Name)
            'MsgBox(Name)

            Width = aryTextFile(53)
            Width = Len(Width)
            Width = Width - 15
            Width = Microsoft.VisualBasic.Mid(aryTextFile(53), 14, Width)
            'MsgBox(Width)

            Height = aryTextFile(56)
            Height = Len(Height)
            Height = Height - 16
            Height = Microsoft.VisualBasic.Mid(aryTextFile(56), 15, Height)
            'MsgBox(Height)

            TextBox1.Text = TextLine




            TextBox2.Text = TextBox2.Text & "INSERT INTO ava_games (Name, description, url, catergory_id, published, image, Width, Height, filetype) VALUES('" & Name & "', '', 'http://www.arcadeskillz.com/games/" & Label2.Text & ".swf', '2', '1', 'http://www.arcadeskillz.com/games/" & Label2.Text & "1.gif', '" & Width & "', '" & Height & "', '1');" & vbNewLine

        Next inf
Avatar billede xabdullahx Nybegynder
05. oktober 2008 - 17:53 #4
2#
hov, havde slet ikke set der også var et .net forum :)
Avatar billede xabdullahx Nybegynder
09. oktober 2008 - 16:22 #5
Kan man svare på sine egne spørgsmål?
Avatar billede xabdullahx Nybegynder
09. oktober 2008 - 16:23 #6
lol, ja det kan man, har løst problemet.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester