-1

我正在创建一个需要身高和体重的程序。高度必须以英尺和英寸计算,重量必须以石头和磅计算。这需要 2 个文本框。

我的问题是如何让文本框变成 1 个变量?

4

1 回答 1

1

在 Textbox Change 或 ButtonClick 中使用此功能:

public long CalculateUnit(int flag , int number) //flag=Textbox Type
{

if(flag==1)
{
int totalInches = (number / 2.54); // This will take a floor function of Centimetres/2.54
int Feet = (totalInches - totalInches % 12) / 12; // This will make it divisible by 12
int inches = totalInches % 12; // This will give you the remainder after you divide by 12
result=inches; //or Feet
}
if(flag==2)
{
int Stone =number;
int Pounds = (Stone*14) ;
int Kilograms = (Pounds/2.2);
result=Kilograms; // or Pounds
}

return result;
}
}
于 2019-11-30T20:01:17.887 回答