mardi 26 mars 2019

How to make a vb.net if statement that does more than 2 if condition is completed?

I'm making a Windows vb.net form application in Visual Studio 2015, where user can either preview an image in a PictureBox by importing it from a file dialog browser, or from a web url. If the user chooses to import it from its computer using the file dialog, the preview will automatically load once it has selected the image file. If user accidentally fills both url and file dialog, i want to clear the TextBox of the url (called url_cover), the TextBox displaying the name of file imported in file dialog (called Browse.FileName) and the PictureBox preview (called preview), and also display a MessageBox telling user to try again, using only one of the import options.

I've already tried making a basic if statement which (until there everything normal) :

If url_cover.Text <> Nothing And Browse.FileName <> Nothing Then
MsgBox("Please do not import image using both file browser and URL.", [vbOKOnly], "Warning") 
url_cover.Clear() Browse.FileName = Nothing preview.Enabled = False

I was expecting all these things to happen if i filled both url and file browser, but i came out with an error telling me that an end of statement was expected after the second instruction (which is url_cover.Clear()). I tried switching the order in which the three instructions had to be executed, but every time it was the same, after the second instruction, an end of statement was expected... Hope my explanations have been clear, and my question is how can i execute more than 2 instructions after the condition of my If statement has been completed.

Aucun commentaire:

Enregistrer un commentaire