Help With A Formula Currently in Visual Basic

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

I have the following VB formula which basically checks the value in four fields and then provides percentage  achievement.  I am trying to mimic the same thing in QB functions but not having much luck. Will appreciate some help. 

Function Rate(varSpeDateOrd As Variant, VarPrimSecOrd As Variant, varSignOrderDate As Variant, varRefOrderDate As Variant) As Double

  Dim var1 As Variant

  Dim var2 As Variant

  Dim var3 As Variant

  Dim var4 As Variant

    If Not IsNull(varSpeDateOrd) Then

   var1 = 0.6

   End If

    If Not IsNull(VarPrimSecOrd) Then

   var2 = 0.3

   End If

    If Not IsNull(varSignOrderDate) Then

   var3 = 0.05

   End If

    If Not IsNull(varRefOrderDate) Then

   var4 = 0.05

   End If

    Rate = (var1 + var2 + var3 + var4)


End Function 

Photo of Arshad Khwaja

Arshad Khwaja

  • 3,152 Points 3k badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 67,448 Points 50k badge 2x thumb
If(not IsNull([Field 1]), 0.6,0)
+
If(not IsNull([Field 2]), 0.3,0)
+
If(not IsNull([Field 3]), 0.05,0)
+
If(not IsNull([Field 4]), 0.05,0)

Note that the IsNull may not be used for text fields, but it appears that you have 4 Date fields.
Photo of Arshad Khwaja

Arshad Khwaja

  • 3,152 Points 3k badge 2x thumb
Thanks a lot.  Very nice and elegant solution.