My company have put me on an urgent project to update one of our existing programs from VB6 to VB.Net. This is happening in two stages, the first of which I personally see as a waste of time, but it's being insisted it be done, is to use the conversion process within Visual Studio and then clean-up errors just to get a compiled version. The size of the program is huge, but as I don't have a say at this point I'm trying to work through the hundreds of compiler errors. I do realise that what I'm doing isn't best practice and is quite a frustrating situation/waste of time.
Basically there are a number of forms, one of which can call any number of other forms, which is dictated by an If statement. When the form is loaded, variables within the new form as assigned and it opens. Some of the variables are commonly named, others are not. So in the VB6 code it would look something like this:
Dim frm As System.Windows.Forms.Form
If x=y Then
frm = New frm1
frm.Variable1 = "VarA"
frm.Variable2 = "VarB"
Else
frm = New frm2
frm.Variable3 = "VarC"
frm.Variable4 = "VarD"
End If
frm.Variable5 = "VarE"
I toyed with putting a separate form object within the If statements, but as they are needed outside of it as well, it doesn't really solve the issue, and as the generic items are used so much for other aspects it wouldn't be practical to duplicate them all within separate assignments.
I was hoping there would be a quick solution along the lines of
frm.Var("Variable1") = "VarA"
But I've not been able to find anything that could be simply implemented across such a large amount of conditions.
Apologies for not encouraging the best practice, because I do realise that any solution wouldn't be it, but I am looking for the quickest implementation so that I can move on to just rewriting the whole program.