let me know by anyone if i have three text boxes Text Box 1,2 and 3.
The First Text Box pick the gross salary from data base on the bases of selection from the combo box.
i want that the 2nd box calculate salary per day ( Gross Salary / 30). And the 3rd text box calculate salary per hour {(Gross salary/30)/8}.
I have try this code but it is not working.
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim grsalry As Integer
Dim ratprday As Integer
grsalry = Val(TextBox1.Text)
ratprday = grsalry / 30
TextBox2.Text = ratprday
End Sub
End Class
Thanks
Loading
VulpesPosted Jun 4, 2014, 10:39 AM
Apart from that, the basic code looks OK (as long as you're only interested in whole currency units) and I've extended it below to include the 'rate per hour' calculation:
Dim grsalry As Integer
Dim ratprday As Integer
Dim ratprhour As Integer
grsalry = Val(TextBox1.Text)
ratprday = grsalry / 30
ratprhour = ratprday / 8
TextBox2.Text = ratprday
TextBox3.Text = ratprhour
Abhishek KumarPosted Jun 4, 2014, 11:31 AM
Please try the below code.
public partial class Form1 : Form
{
int salarypM=0;
int salaryD=0;
public void calculateSalary()
{
textBox1.Text = "9000";
salarypM = Convert.ToInt32(textBox1.Text) / 30;
textBox2.Text = salarypM.ToString();
textBox3.Text = (salarypM / 8).ToString();
}
public Form1()
{
InitializeComponent();
calculateSalary();
}
}
Hope this will help.