Console App - simple argument check

I’m trying to create my first console app and I’ve managed somehow to have it work fine, everything but the argument handling. I want the app to run with and without arguments so i thought to check with a if routine but i’m getting exceptions if I run the app without an argument.

My run event check is as follows

  if (args(1)) = "" then
    Days = -7
    Days = -(val(args(1)))
  End if

The whole app has about 30 to 40 lines of code so i’d like to keep it simple without adding massive classes or functions to handle the argument check

Thank you,

[quote=259462:@Matteo Saitta][/quote]

You cannot look at args(1) if there is no args(1). Try this instead :

if args.ubound = 0 then Days = -7 elseif args.ubound >= 1 then Days = -(val(args(1))) End if

I managed to solve it in the meanwhile using pretty much what @Michel Bujardet suggested. Thank you!