Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
1.33/5 (2 votes)
I want to create a form in which i have to fill two value in two different textbox... i wantt the multiplication of the textbox value in other textbox.. i tried but didnt get... can you please help me and i want to save the textbox value in databse.. thanks in advance
Posted
Updated 13-Apr-22 1:55am
Comments
krishnamittal 2-Jan-13 11:42am    
TextBox3.Text=(Convert.ToInt32(TextBox1.Text)*Convert.ToInt32(TextBox2.Text);

This code is error generate.

plz how to multiply value of two textboxes into the third text box

VB
Private Sub textbox1_EditValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textbox1.EditValueChanged
        If textbox1.Text <> "" Then
textbox3.text=cint(textbox1.text)*1
        End If
    End Sub
Private Sub textbox2_EditValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles textbox2.EditValueChanged
        If textbox2.Text <> "" and textbox2.Text <> ""  Then
textbox3.text=cint(textbox1.text)*cint(textbox2.text)
        End If
    End Sub
 
Share this answer
 
dim mul as int64
MUL=CONVERT.TOINT64(textbox1.text)* convert.toint64(textbox2.text)
textbox3.text=convert.tostring(mul)
 
Share this answer
 
JavaScript Solution is as follows:
JavaScript
function multiply()
{
   
   var textValue1 = document.getElementById('TextBox1').value;
   var textValue2 = document.getElementById('TextBox2').value;

   document.getElementById('TextBox3').value = textValue1 * textValue2;

}
 
Share this answer
 
v2
Comments
Shrikesh_kale 8-Jul-15 0:40am    
how to call on text change
if you want to diplay this value u can write like this.
C#
TextBox3.Text=(Convert.ToInt32(TextBox1.Text)*Convert.ToInt32(TextBox2.Text);


or if u want use this textbox3 value for again calculation purpose means again u need to convert this texbox3 value

like
C#
convert.Toint32(TextBox3.text)
 
Share this answer
 
v2
Firstly you need to type cast values of both text boxes into integer.

C#
Example: TextBox3.Text=Convert.ToString(Convert.ToInt32(TextBox1.Text)*Convert.ToInt32(TextBox2.Text));
 
Share this answer
 
v3
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace salarycount
{
public partial class salarycount : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}



protected void txtmday_TextChanged(object sender, EventArgs e)
{
if ((!string.IsNullOrEmpty(txtsalary.Text)) && (!string.IsNullOrEmpty(txtmday.Text)) && (!string.IsNullOrEmpty(txtpday.Text)))
{
txtaday.Text = ( Convert.ToInt32(txtmday.Text) - Convert.ToInt32(txtpday.Text)).ToString();
txtnsalary.Text = (Convert.ToInt32(txtsalary.Text) / Convert.ToInt32(txtmday.Text) * Convert.ToInt32(txtpday.Text)).ToString();
}
}

protected void txtpday_TextChanged(object sender, EventArgs e)
{
if ((!string.IsNullOrEmpty(txtsalary.Text)) && (!string.IsNullOrEmpty(txtmday.Text)) && (!string.IsNullOrEmpty(txtpday.Text)))
{
txtaday.Text = (Convert.ToInt32(txtmday.Text) - Convert.ToInt32(txtpday.Text)).ToString();
txtnsalary.Text = (Convert.ToInt32(txtsalary.Text) / Convert.ToInt32(txtmday.Text) * Convert.ToInt32(txtpday.Text)).ToString();
}
}

protected void txtsalary_TextChanged(object sender, EventArgs e)
{
if ((!string.IsNullOrEmpty(txtsalary.Text)) && (!string.IsNullOrEmpty(txtmday.Text)) && (!string.IsNullOrEmpty(txtpday.Text)))
{
txtnsalary.Text = (Convert.ToInt32(txtsalary.Text) / Convert.ToInt32(txtmday.Text) * Convert.ToInt32(txtpday.Text)).ToString();
}
}
}
}
 
Share this answer
 
Comments
CHill60 13-Apr-22 11:21am    
An uncommented, unformatted code dump is not a solution. What if your text boxes had something other than numbers in them (or were blank, as some of them will be) - you will get errors galore. Plus you are repeating code - abstract that out into a function! I'm afraid this is a very poor solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900