Is there way I can declare 70 different variables in a loop instead of declaring each one?
I wanted to do something like below:
For i As Integer = 0 To 70
Dim Para + i AS OracleParameter
Next
Instead of declaring as below:
Dim Param1 AS OracleParameter
Dim Param2 AS OracleParameter
Dim Param3 AS OracleParameter
…
Dim Param70 AS OracleParameter
Use an array:
Dim Param(69) As OracleParameter
For i As Integer = 0 To Param.Length - 1
Param(i) = New OracleParameter(..)
'' etc..
Next
I have never seen such a method, but in looking at it, why wouldn't you use a list or a KeyValuePair using the index as the key? I would really recommend using something of that nature, even if you keep the word "Param" as part of the key.
Dim Parameters as New KeyValuePair(Of String, OracleParameter)
For i AS Integer = 0 To 70
Parameters.Add("Param" & i.ToString(), New OracleParameter)
Next
This could then be accessed at any time using (e.g.)
Parameters("Param66").Value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With