2 Replies - 16587 Views - Last Post: 02 January 2010 - 10:22 PM Rate Topic: -----

#1 nutskataketo  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-September 07

eval function in VB.NET

Post icon  Posted 18 September 2007 - 02:29 AM

I am working with VB.NET, I have many mathematical equations in my windows application, which differ according to many options I selected from previous form. So I m using thesse equation as strings in database and according to the selected options from the previous form it drag the its equation, which I concatinate to a variable (number) according to the selected age. So this equation doesn't work because it defined as nvchar in the databse and the variable is number, I tried the function eval() which I use in asp to solve this but it didn't work. I want to know if there is a function in VB.NET can solve this problem or what can I do to solve it.

			Dim laib As String
			Dim laia As String
			Dim laii As String
			Dim lai As Double
			Dim fac As Decimal
			Me.LAITableAdapter.FillBy(Me.EcoponicDS.LAI, trt_id, gh_type)
			CB.DataSource = EcoponicDS.Tables("LAI")
			CB.ValueMember = "factor"
			fac = CB.SelectedValue.ToString()
			CB.ValueMember = "equ_bef"
			laib = CB.SelectedValue.ToString()
			CB.ValueMember = "equ_aft"
			laia = CB.SelectedValue.ToString()
			laii = (laib & age & laia)
			lai = eval(laii)   'this doesn't work, cannot convert from string to type int
 


Is This A Good Question/Topic? 0
  • +

Replies To: eval function in VB.NET

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: eval function in VB.NET

Posted 18 September 2007 - 04:33 AM

I'm not 100% positive what you're attempting to do here, you didnt give a very good explanation, but I believe this is the solution you're looking for

Dim laib As String
Dim laia As String
Dim laii As String
Dim lai As Double
Dim fac As Decimal
Me.LAITableAdapter.FillBy(Me.EcoponicDS.LAI, trt_id, gh_type)
CB.DataSource = EcoponicDS.Tables("LAI")
CB.ValueMember = "factor"
fac = Convert.ToDecimal(CB.SelectedValue.ToString())
CB.ValueMember = "equ_bef"
laib = Integer.TryParse(CB.SelectedValue, New Integer())
CB.ValueMember = "equ_aft"
laia = Integer.TryParse(CB.SelectedValue, New Integer())
laii = (laib & age & laia)
lai = Convert.ToDouble(laii)   'this doesn't work, cannot convert from string to type int



If I'm way off base as to what you're trying to accomplish, please let me know with a better explanation and Ill try to help once again :)
Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon


Reputation: 2270
  • View blog
  • Posts: 9,496
  • Joined: 29-May 08

Re: eval function in VB.NET

Posted 02 January 2010 - 10:22 PM

Update: vb.net code snippet for eval like behavior.:- EvaluateEquation
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1