title: Run string as Code
body: <p>How to call an existing VB6 function and pass parameters or execute a statement utilizing some defined objects dynamically? E.g. </p>
  
  <pre><code>Private Const KONST = 123.45
  Private Function First()
      Dim var1 As String
      Dim var2 As Date
      Dim var3 As Integer
      ...
      var3 = Second(var1)                 'LINE 1
      ...
      var2 = var2 + IIf(var3 &gt; KONST, 1, -1) 'LINE 2
      ...
      var2 = var2 * KONST                 'LINE 3
      ...
  End Function
  
  Private Function Second(ByVal str As String) As Integer
      Second = CInt(str)
  End Function
  </code></pre>
  
  <p>At line 1: Name of the function <code>Second</code> could be dynamic while using <code>var1</code> and returning value</p>
  
  <p>At line 2: The whole <code>IIf</code> should be dynamic using <code>var3</code> and <code>KONST</code></p>
  
  <p>At line 3: Whole <code>var2 * KONST</code> should be dynamic i.e. here i may write <code>var2 + KONST</code> or <code>var3 / KONST</code> or <code>var3 + 222</code> or <code>1 + 2</code> or <code>myCollection.Item("item_Key")</code>.</p>
  
  <p>All such dynamic configuration will be in a config file.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>I am trying to make grid layout and data population dynamic. By grid layout i mean number of columns, their title, order, format, etc. And by population i mean loading data into the grid, in doing so, sometimes we resolve a database value with some of our Enums, we apply some logic on data before showing it, value of one column is based on value of other column, etc. Though, upto some extent, this can be achieved via databases views, but to have all such logic in a central location we do such things from source code. Therefore i need some way to call my vb6 code dynamically and define the calling (function name, parameters, enums, types, statement) in a config file.</p>