Help me out here, I must be doing something wrong,
The first example here works fine
DatabaseType = Array.Find(pArgs, Function(s As String) s.ToLower.Contains("/db:")).Replace("/db:", "")
but if that was false and my variable turned out to be nothing then it throws and object ref exception, so as a result I wrapped an IF around it, but then it never returns true, and also it doesnt populate the variable, like the one below:
If DatabaseType = Array.Find(pArgs, Function(s As String) s.ToLower.Contains("/db:")).Replace("/db:", "") Then LogAndTrace("Database Type", DatabaseType)
What I need to do is :
Basically I have a num of commandlines arguments I am getting and I need to distiguish what they are each according to their prefix and assign them to the right property , but they are not always going to be there so I wanted to first see if it exist then replace the prefix with nothing, assign it to the property and write it to the log.
It’s a bad idea to try to perform assignment within the condition of an
Ifstatement.I suspect you want something like this:
(That’s using a local variable… if you want to assign a property, I’d do that within the
Ifblock, when you’ve performed the replacement.)