Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.

de tai ltm2

5 posters

Go down

de tai ltm2 Empty de tai ltm2

Bài gửi by quocanh 15/4/2010, 22:43

ai code duoc bai 1 may tinh roi up len cho moi nguoi tham khao di nao
quocanh
quocanh
Góp sức
Góp sức

Tổng số bài gửi : 86
Join date : 18/09/2009
Age : 41
Đến từ : HỐ CHÍ MINH CITY

Về Đầu Trang Go down

de tai ltm2 Empty Code ne bac, giao dien thi tu ve nhe.

Bài gửi by dragoniron 16/4/2010, 09:19

private void ResultOperator()
{
float vR = 0, vR1 = 0, vRs = 0;
bool vIsError = false;
//Using this code when set data format by VietNam
txtValue.Text = txtValue.Text.Replace(
".", ",");
vR1 =
float.Parse(txtValue.Text);
vR =
float.Parse(hfResult.Value);
switch (hfOperator.Value.ToString())
{
case "/":
if(vR1 == 0)
{
ltrError.Text =
"Can not devide for zero value.";
vIsError =
true;
}
else
{
vRs = vR/vR1;
}
break;
case "*":
vRs = vR * vR1;
break;
case "+":
vRs = vR + vR1;
break;
case "-":
//Check if add operator in last item then replace with new operator
vRs = vR - vR1;
break;
default:
vIsError =
true;
vRs = vR1;
break;
}
hfResult.Value = vRs.ToString();
if(!vIsError)
{
txtValue.Text = vRs.ToString();
}
}
///
/// Set value from button to display text when keypress.
///

protected void Button_Click(object sender, EventArgs e)
{
Button vbtn = sender
as Button;
string vValue = "";
if (vbtn == null) { return; }
vValue = vbtn.Text;
switch (vValue)
{
case "/":
case "*":
case "+":
case "-":
//Check if add operator in last item then replace with new operator
if (("+-*/".IndexOf(Right(txtDisplay.Text.Trim(), 1)) != -1) && ("+-*/".IndexOf(hfLastValue.Value.ToString().Trim()) == -1))//Kiem tra khi nhan toan tu cung luc
{
txtDisplay.Text += txtValue.Text;
}
else if (("+-*/".IndexOf(Right(txtDisplay.Text.Trim(), 1)) != -1) && ("+-*/".IndexOf(vValue.Trim()) != -1))//Thay doi toan tu khi da co 1 toan tu hien hanh
{
txtDisplay.Text = Left(txtDisplay.Text.Trim(), txtDisplay.Text.Trim().Length - 1) + vValue +
" ";
}
if ("+-*/".IndexOf(hfLastValue.Value.ToString().Trim()) == -1)
{
ResultOperator();
vValue =
" " + vValue + " ";
}
else
{
vValue =
"";
}
if ((txtDisplay.Text.Trim() == ""))// && (float.Parse(hfResult.Value.ToString()) >= 0)
{
txtDisplay.Text += hfResult.Value.ToString();
}
txtDisplay.Text += vValue;
hfOperator.Value = vbtn.Text;
break;
default:
if (("+-*/".IndexOf(hfLastValue.Value.ToString().Trim()) != -1) || (hfOperator.Value == "="))// &&(txtValue.Text.Length>1))
{
txtValue.Text =
"";
}
if (txtDisplay.Text.Trim() != "") //Not fill when isempty
{
if (("+-*/".IndexOf(hfOperator.Value.Trim()) == -1))
{
txtDisplay.Text += vValue;
}
}
txtValue.Text += vValue;
break;
}
hfLastValue.Value = vbtn.Text;
}

dragoniron
Khởi đầu
Khởi đầu

Tổng số bài gửi : 41
Join date : 23/09/2009
Age : 40
Đến từ : Tiền Giang

http://www.ampharco.com

Về Đầu Trang Go down

de tai ltm2 Empty Re: de tai ltm2

Bài gửi by nguyenduc 16/4/2010, 13:23

Viết code khủng quá, đọc hổng có hỉu Sad(

nguyenduc
Cống hiến
Cống hiến

Tổng số bài gửi : 312
Join date : 17/09/2009
Age : 44
Đến từ : Bến tre - Hồ chí minh

Về Đầu Trang Go down

de tai ltm2 Empty Re: de tai ltm2

Bài gửi by quangbao 16/4/2010, 15:45

dragoniron đã viết:private void ResultOperator()
{
float vR = 0, vR1 = 0, vRs = 0;
bool vIsError = false;
//Using this code when set data format by VietNam
txtValue.Text = txtValue.Text.Replace(
".", ","
Bạn nén luôn code & giao diện thành file share cho pà con tham khảo được ko ? Coi cái này cũng chả biết cáo nào ứng với cài nào. Đa tạ bác 
quangbao
quangbao
Cống hiến
Cống hiến

Tổng số bài gửi : 127
Join date : 16/09/2009
Age : 40

https://facebook.com/truongquangbao

Về Đầu Trang Go down

de tai ltm2 Empty Re: de tai ltm2

Bài gửi by quocanh 16/4/2010, 21:21

dung roi do bac, nhin vo cha hieu cai gi het
quocanh
quocanh
Góp sức
Góp sức

Tổng số bài gửi : 86
Join date : 18/09/2009
Age : 41
Đến từ : HỐ CHÍ MINH CITY

Về Đầu Trang Go down

de tai ltm2 Empty Re: de tai ltm2

Bài gửi by mr_h 19/4/2010, 15:00

Hiểu được hay không chưa biết . Nhưng nhìn vô thì không muốn hiểu luôn .
mr_h
mr_h
Khởi đầu
Khởi đầu

Tổng số bài gửi : 41
Join date : 19/09/2009

Về Đầu Trang Go down

de tai ltm2 Empty Re: de tai ltm2

Bài gửi by Sponsored content


Sponsored content


Về Đầu Trang Go down

Về Đầu Trang

- Similar topics

 
Permissions in this forum:
Bạn không có quyền trả lời bài viết