Powered by SpreadsheetGear
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<title>VB.NET Spreadsheet Component Evaluate Formula Using ASP.NET and SpreadsheetGear</title>
<meta content="VB.NET spreadsheet component evaluate formula sample demonstrating SpreadsheetGear, a royalty free Microsoft Excel compatible spreadsheet component for the Microsoft .NET Framework featuring the fastest and most complete calculation engine available. Create, read, modify, calculate and write Microsoft Excel workbooks from your Microsoft .NET, ASP.NET, C#, VB.NET and Microsoft Office solutions. Integrates with Microsoft Visual Studio .NET, including IntelliSense and Dynamic Help." name="description" />
<script language="VB" runat="server">
    Sub Page_Load(sender As [Object], e As EventArgs)
        If Page.IsPostBack Then
            ' Create a new empty workbook and get the first sheet. 
            Dim workbook As SpreadsheetGear.IWorkbook = SpreadsheetGear.Factory.GetWorkbook()
            Dim worksheet As SpreadsheetGear.IWorksheet = workbook.Worksheets(0)
            ' Evaluate the input formula
            Dim result As Object = worksheet.EvaluateValue(TextBox1.Text)
            ' Display the result to the user
            Dim displayValue As String
            If result Is Nothing Then
                displayValue = "Empty cell or invalid formula."
            Else If TypeOf result Is SpreadsheetGear.ValueError Then
                Dim valueError As SpreadsheetGear.ValueError = CType(result, SpreadsheetGear.ValueError)
                displayValue = "Value Error: #" + valueError.ToString().ToUpper() + "!"
                displayValue = result.ToString()
            End If
            LabelResult.Text = "<strong>Result calculated from EvaluateValue</strong>: " + displayValue
            TextBox1.Text = "TEXT(STDEV(1, 2, 3, 4), ""0.00"")"
        End If
    End Sub 'Page_Load
<style type="text/css">
    background-color: #EEEEEE;
    border-style: solid;
    border-width: 1px;
    border-color: #5959AA;
    color: #000000;
    font-size: 12px;
    background-color: #5959AA;
    color: #FFFFFF;
    font-weight: bold;
<body style="font-family: Verdana;">
<h5>VB.NET Spreadsheet Component Evaluate Formula Sample<br />for ASP.NET Using <a href="https://www.spreadsheetgear.com/products/spreadsheetgear.net.aspx">SpreadsheetGear</a></h5>
<form id="form1" runat="server">
  <table class="tableStyle "cellpadding="4" cellspacing="0">
    <tr class="tableHeaderStyle">
      <td colspan="3">Evaluate Formula Sample</td>
      <td>Enter Excel compatible formula to evaluate:</td>
      <td><asp:TextBox id="TextBox1" Columns="80" runat="server"/></td>
      <td align="right"><asp:Button ID="ButtonSubmit" Text="Evaluate" runat="server"/></td>
  <br />
  <asp:Label id="LabelResult" Font-Size="14px" runat="server"/>
<h6>Copyright 2005 © SpreadsheetGear LLC. All Rights Reserved.<br /><a href="https://www.spreadsheetgear.com">www.spreadsheetgear.com</a></h6>