473,395 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to use <Script Language =VBScript >

126 100+
Hi Helpful Good Guys,

I need your help. Please help me.

I have been asked to transfer the FUNCTION FCalculate from WebFrmLoan.aspx to Web Page CODEBEHIND. The Functon event is to calculate the Loan Monthly Repayment amount.


I have not done it before using VBScript and it generated this error message.

Option Strict On requires all Function, Property, and Operator declarations to have an 'As' clause.

This is the coding that generate the error message:
Expand|Select|Wrap|Line Numbers
  1. <script language= "vbscript" runat=server>               
  2.         Protected Function FCalculate(ByVal Sender As Object, ByVal e As EventArgs)
  3.             Dim intPaym As Double = 0
  4.             intPaym = (CType(Me.txtLoanAmt.Text, Double) / CType(Me.txtTotalMonth.Text, Long))
  5.         End Function
  6.     </script> 
  7.  
--------------------------------
Here are the overall coding from WEB PAGE CODEBEHIND:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebFrmClientSideScript.aspx.vb" Inherits="ASPNET2008DataEntry.WebFrmClientSideScript" %>
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml" >
  6. <head runat="server">
  7.     <title>Loan Repayment Page</title>
  8.     <link href="StyleSheet1.css" rel="stylesheet" type="text/css" />
  9.     <style type="text/css">
  10.         .style1
  11.         {
  12.             width: 547px;
  13.         }
  14.     </style>
  15. </head>
  16. <!-- -------------------------------------------------------------------- -->
  17.     <script language= "vbscript"  runat= server>
  18.  
  19.         Protected Function FCalculate(ByVal Sender As Object, ByVal e As EventArgs)
  20.             Dim intPaym As Double = 0
  21.             intPaym = (CType(Me.txtLoanAmt.Text, Double) / CType(Me.txtTotalMonth.Text, Long))
  22.         End Function
  23.     </script>  
  24. <!-- -------------------------------------------------------------------- -->
  25. <body>
  26.     <form id="form1" runat="server">
  27.     <div class="LeftMargin">
  28.         <asp:Label ID="lbl1" CssClass="labelBanner" runat="server"
  29.                  Text="Loan Monthly Repayment Calculation" >
  30.         </asp:Label>                 
  31.     </div>        
  32.     <br />
  33.  
  34.     <div class="LeftMargin">
  35.         <table style="width:100%;"
  36.                 <tr>
  37.                     <td align="left" class="style1">
  38.                         <asp:Label ID="lbl2" CssClass="labelText" runat="server" Width="300px" 
  39.                                  Text="Loan Amount $:" ></asp:Label>
  40.                         <asp:TextBox ID="txtLoanAmt" CssClass="textbox" runat="server"
  41.                                    EnableViewState="true" AutoPostBack="false" TabIndex="1"></asp:TextBox>                        
  42.                     </td> 
  43.                  </tr>
  44.  
  45.                  &nbsp;
  46.                  <tr>
  47.                     <td class="style1">
  48.                         <asp:Label ID="lbl3" CssClass="labelText" runat="server" Width="300px"
  49.                                  Text="Repayment Months Count :"></asp:Label>
  50.                         <asp:TextBox ID="txtTotalMonth" CssClass="textbox" runat="server"
  51.                                   EnableViewState="true" AutoPostBack="false" TabIndex="2"></asp:TextBox>                                     
  52.                     </td>                  
  53.                     &nbsp;
  54.                     <td>
  55.                         <asp:Label ID="lbl4" CssClass="labelText" runat="server" Width="400px"
  56.                                  Text="Monthly Repayment Amount :"></asp:Label>
  57.                         <asp:TextBox ID="txtPayAmt" CssClass="textbox" runat="server"
  58.                                  EnableViewState="true" AutoPostBack="false" TabIndex="3"
  59.                                   Enabled="false" ></asp:TextBox>
  60.  
  61.                     </td>
  62.                  </tr> 
  63.  
  64.  
  65.                  <tr class="LeftMargin">
  66.                     <td>
  67.                         <asp:Label ID="lbl5" runat="server" Width="200px"></asp:Label>
  68.                         <asp:Button ID="BtnCalculate" CssClass="Button" runat="server"
  69.                                  Text="Monthly Payment Calculate" OnClick="FCalculate"
  70.                                   Width="200px" />                             
  71.                     </td>
  72.                  </tr>
  73.  
  74.         </table>      
  75.     </div>
  76.  
  77.     </form>
  78. </body>
  79. </html>
  80.  
  81.  
  82.  
Aug 3 '10 #1

✓ answered by Frinavale

Fistly, VBScript is not a .NET language as far as I know. VBScript is used for classic asp development (not ASP.NET).

You have posted VB.NET code...however a Function returns something to the calling code, whereas a Sub does not return anything. Since your method does not return anything to the calling code, change the Function into a Sub. Also, consider using the "Handles" keyword to handle events for controls.

-Frinny

4 10033
Frinavale
9,735 Expert Mod 8TB
Fistly, VBScript is not a .NET language as far as I know. VBScript is used for classic asp development (not ASP.NET).

You have posted VB.NET code...however a Function returns something to the calling code, whereas a Sub does not return anything. Since your method does not return anything to the calling code, change the Function into a Sub. Also, consider using the "Handles" keyword to handle events for controls.

-Frinny
Aug 3 '10 #2
lenniekuah
126 100+
Hi Frinavale,
Thank you for your additional information
.

Due to my lack of experences and knowledge can you please make changes to my posted coding using HANDLES ? That would give me the opportunity to understand it logically.

Thank you for your help.
Aug 4 '10 #3
Frinavale
9,735 Expert Mod 8TB
Well it's all in the method signature.
If you have a button called "btn_FCalculate" and you want to handle the button click event for this button. You would implement a method that Handles that event:

Expand|Select|Wrap|Line Numbers
  1. Protected Sub btn_FCalculate(ByVal Sender As Object, ByVal e As EventArgs) Handles btn_FCalculate.Click
  2.   '....
  3. End Sub
Now when the button is clicked, and the Click event is fired, that method will be executed (it will handle the event) :)

-Frinny
Aug 4 '10 #4
lenniekuah
126 100+
Hi Wonderful Frinavale,
Thank you for helping me. I have tried out your suggestion and it's working.
Yaaa....Hooo
Aug 5 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Randell D. | last post by:
Folks, Do I need to use the 'type' in the javascrpit external load request below? Is it mandatory or optional? I've not found a clear reference on this... <script language='JavaScript'...
2
by: jd | last post by:
Hi, I have an xsl as below. I am trying to loop using <xsl:for-each> and in the select attribute of <xsl:for-each> i am getting the nodeset from the external javascript function in the <CDATA>...
4
by: cbakopanos | last post by:
Is there any way to write client side script purelly on C#? -- Costas Bakopanos MCSD .NET / MCT
1
by: jason | last post by:
Pardon the newbie question... What's the difference between (asp.net)VB code inside one versus the other. And why have both?
44
by: rhythmace | last post by:
W3C HTML validator passes this: .... <script type="text/javascript" src="foo.js"> <script type="text/javascript"> ....script in here... </script> ....
8
by: howa | last post by:
Just found a funny things.. in HTML4's dtd, http://www.w3.org/TR/html4/strict.dtd language is not valid, i.e. <!ELEMENT SCRIPT - - %Script; -- script statements --> <!ATTLIST...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.