DivRem Example Syntax VB.NET ASP.NET | DivRem | Source Code

DivRem Example Syntax VB.NET ASP.NET | DivRem | Source Code

Summary: – Illustrates using with in VB.NET ASP.NET.



Purpose:
takes an dividend, divisor, and remainder as Int32 or Int64
and returns quotient as same data type. Remainder is passed by
reference and it gets updated with the remainder when the function
executes.

Syntax:
DivRem(dividend32, divisor32, byRef remainder32)

Parameters Description
dividend32 int32
divisor32 int32
remainder32 byRef int32

Result Data Type Description
int32 quotient

Quick Example
Dim int32Dividend As Int32 = 7
Dim int32Divisor As Int32 = 5
Dim int32Quotient As Int32 = 0
Dim int32Remainder As Int32 = 0

Syntax2:
DivRem(dividend64, divisor64, byRef remainder64)

Parameters Description
dividend64 int64
divisor64 int64
remainder64 byRef int64

Result Data Type Description
int64 quotient

Step 1: Click on Visual Basic to Cut-n-paste code into DivRem.aspx.vb

 
Imports System
Imports System.IO
Imports System.Data
Imports System.Math
 
'********************************************************************************
' Purpose: takes an dividend, divisor, and remainder as Int32 or Int64
' and returns quotient as same data type.  Remainder is passed by
' reference and it gets updated with the remainder when the function
' executes.
'
' *******************************************************************************
' Syntax: 	 DivRem(dividend32, divisor32, byRef remainder32)
'
' Parameter1: dividend32 - int32
'
' Parameter2: divisor32 - int32
'
' Parameter3: remainder32 - byRef int32
'
' Result: int32 - quotient
'
' ******************************************************************************
' Syntax2: 	DivRem(dividend64, divisor64, byRef remainder64)
'
'
' Parameter1: dividend64 - int64
'
' Parameter2: divisor64 - int64
'
' Parameter3: remainder64 - byRef int64
'
' Result: int64 - quotient
'
' Quick Example: Dim int32Dividend As Int32 = 7
' Dim int32Divisor As Int32 = 5
' Dim int32Quotient As Int32 = 0
' Dim int32Remainder As Int32 = 0
 
 
 
Partial Class _DivRem
    Inherits System.Web.UI.Page
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
 
 
        Label1.Text = "Example #1: 	DivRem(dividend as int32, divisor as int32, byRef remainder as int32)"
        Dim int32Dividend As Int32 = 7
        Dim int32Divisor As Int32 = 5
        Dim int32Quotient As Int32 = 0
        Dim int32Remainder As Int32 = 0
 
        int32Quotient = DivRem(int32Dividend, int32Divisor, int32Remainder)
 
 
        TextBox1.Text = "Quotient=" & int32Quotient ' Returns 1
 
 
        Label2.Text = "Example #2: 	DivRem(dividend as int64, divisor as int64, byRef remainder as int64)"
        Dim int64Dividend As Int64 = 7
        Dim int64Divisor As Int64 = 5
        Dim int64Quotient As Int64 = 0
        Dim int64Remainder As Int64 = 0
 
        int64Quotient = DivRem(int64Dividend, int64Divisor, int64Remainder)
 
 
        TextBox2.Text = "Quotient=" & int64Quotient ' Returns 1
 
 
 
 
    End Sub
End Class

Step 2: Click on XML to Cut-n-paste code into DivRem.aspx

< %@ Page Language="VB" AutoEventWireup="false" CodeFile="DivRem.aspx.vb" Inherits="_DivRem" %>
 
< !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h1><asp:label ID="Label1" runat="server" Text="Label"></asp:label> </h1>
         <asp:textbox ID="TextBox1" runat="server"></asp:textbox><br />
          <h1><asp:label ID="Label2" runat="server" Text="Label"></asp:label> </h1>
         <asp:textbox ID="TextBox2" runat="server"></asp:textbox><br />
          <h1><asp:label ID="Label3" runat="server" Text="Label"></asp:label> </h1>
         <asp:textbox ID="TextBox3" runat="server"></asp:textbox><br />
 
 
 
    </div>
    </form>
</body>
</html>

Prerequistes:

  1. Install Visual Web Developer 2010
  2. Install SQL Server Express
  3. Download Northwind and Pubs Databases
  4. Attach Northwind Database to Databases in Sql Express
  5. Attach pubs Database to Databases in Sql Express

Notes:

  • You can build your own library of syntax examples by using same web site over and over and just add new web forms to it.

Instructions:

VB.NET ASP.NET Syntax Functions MathFunctions DivRem
  1. Use Visual Web Developer 2010
  2. Create new web site;
    • Click File/New Web Site
    • Select ASP.NET Website Template
    • Select Visual Basic for Language
    • name of Web Site could be VBNET_ASPNET_Syntax.
  3. Add New folder named “Functions”
    • Right-click project name in solution explorer;
    • add new folder;
    • name of folder could be: Functions
  4. Add New subfolder named “MathFunctions”
    • Right-click Functions folder in solution explorer;
    • add new folder;
    • name of folder could be: MathFunctions
  5. Add Web Form Named DivRem to MathFunctions folder
    • Right-click MathFunctions folder;
    • add new item;
    • Select Web Form
    • Check place code behind in separate file
    • Web Form name could be DivRem
  6. Click on Visual Basic in step 1 at the top of this page to copy code into code-behind DivRem.aspx.vb
  7. Click on XML in step 2 above to copy code into web form DivRem.aspx
  8. Right-click on DivRem.aspx in solution explorer and select view in browser