user1949326
user1949326

Reputation: 1

Visual Basic- "IF" doesn't end

If My.Computer.FileSystem.FileExists("pack/locale_ro.epk") Then My.Computer.FileSystem.DeleteFile("pack/locale_ro.epk")

    PB_GSM.Value = 10

    If My.Computer.FileSystem.FileExists("pack/locale_ro.eix") Then My.Computer.FileSystem.DeleteFile("pack/locale_ro.eix")

    PB_GSM.Value = 20

    If My.Computer.FileSystem.FileExists("pack/root.epk") Then My.Computer.FileSystem.DeleteFile("pack/root.epk")

    PB_GSM.Value = 30

    If My.Computer.FileSystem.FileExists("pack/root.eix") Then My.Computer.FileSystem.DeleteFile("pack/root.eix")

    PB_GSM.Value = 40

    My.Computer.Network.DownloadFile("http://example")

I believe i wrote everything correct, but it doesn't matter how i write the "if"-s , i can not end them. if i wrote End if next to a line it says something like "End if must be preceded by a matching if". And another problem , the line about the download link is underlined and it says"Overload resolution failed because no accessible 'DownloadFile' accepts this number of arguments".

P.S: this is a try for a metin2 patcher, i do not know exactly how to do it but i'm sure this is a way to update the game only at the files that i neeed.Thanks for help:)

Upvotes: 0

Views: 259

Answers (2)

LarsTech
LarsTech

Reputation: 81675

You have them all in one line. Don't put anything after the "Then" keyword.

If My.Computer.FileSystem.FileExists("pack/locale_ro.epk") Then
  My.Computer.FileSystem.DeleteFile("pack/locale_ro.epk")
  PB_GSM.Value = 10
End If

If looking for an else-if situation, this would be the syntax:

If My.Computer.FileSystem.FileExists("pack/locale_ro.epk") Then
  My.Computer.FileSystem.DeleteFile("pack/locale_ro.epk")
  PB_GSM.Value = 10
ElseIf My.Computer.FileSystem.FileExists("pack/locale_ro.eix") Then
  My.Computer.FileSystem.DeleteFile("pack/locale_ro.eix")
  PB_GSM.Value = 20
' etc, etc
End If

Note though that this will only run the code on the first "True" line found.

For the DownloadFile, you also need to specify the destination:

My.Computer.Network.DownloadFile("http://example", "c:\temp\myfile.txt")

Substitute the c:\temp\ path with the one you are using.

Upvotes: 3

kencordero
kencordero

Reputation: 151

When you post the Then statement followed by an expression that closes that If statement. You have, in essence, already closed all your If statements.

Upvotes: 2

Related Questions