Browse Source

Decimal done

test
lLewdie 1 year ago
parent
commit
ff79a11e56
  1. 36
      num-converter/WebForm1.aspx
  2. 31
      num-converter/WebForm1.aspx.cs
  3. 9
      num-converter/WebForm1.aspx.designer.cs

36
num-converter/WebForm1.aspx

@ -9,6 +9,16 @@
.auto-style1 {
width: 100%;
}
.auto-style2 {
height: 30px;
}
.auto-style3 {
width: 284px;
}
.auto-style4 {
height: 30px;
width: 284px;
}
</style>
</head>
<body>
@ -27,19 +37,20 @@
</div>
<table align="center" class="auto-style1">
<tr>
<td class="auto-style3">
Source Positional System</td>
<td>
Target Positional System</td>
</tr>
<tr>
<td class="auto-style4">
<asp:DropDownList ID="ddlSourcePosNum" runat="server">
<asp:ListItem Value="0">Select An Option</asp:ListItem>
<asp:ListItem Value="1">Decimal</asp:ListItem>
<asp:ListItem Value="2">Binary</asp:ListItem>
<asp:ListItem Value="3">Octal</asp:ListItem>
<asp:ListItem Value="4">Hexadecimal</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:Label ID="Label1" runat="server" Text="Convert to"></asp:Label>
</td>
<td>
<td class="auto-style2">
<asp:DropDownList ID="ddlTargetPosNum" runat="server">
<asp:ListItem Value="0">Select An Option</asp:ListItem>
<asp:ListItem Value="1">Decimal</asp:ListItem>
@ -50,28 +61,21 @@
</td>
</tr>
<tr>
<td>
<td class="auto-style4">
<asp:TextBox ID="txtInput" runat="server"></asp:TextBox>
</td>
<td>&nbsp;</td>
<td>
<td class="auto-style2">
<asp:Label ID="lblResult" runat="server" BorderStyle="Double"></asp:Label>
</td>
</tr>
<tr>
<td>
<td class="auto-style3">
<asp:Button ID="btnConvert" runat="server" OnClick="btnConvert_Click" Text="Convert" />
</td>
<td>&nbsp;</td>
<td>
<asp:Button ID="btnClear" runat="server" OnClick="btnClear_Click" Text="Clear" />
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</form>
</body>

31
num-converter/WebForm1.aspx.cs

@ -34,6 +34,37 @@ namespace num_converter
}
lblResult.Text = Result;
}
if (ddlSourcePosNum.SelectedIndex == 1 && ddlTargetPosNum.SelectedIndex == 3)
{
DecimalNum = Convert.ToInt32(txtInput.Text);
while (DecimalNum > 0)
{
Remainder = DecimalNum % 8;
Result = Remainder.ToString() + Result;
DecimalNum /= 8;
}
lblResult.Text = "0x" + Result;
}
if (ddlSourcePosNum.SelectedIndex == 1 && ddlTargetPosNum.SelectedIndex == 4)
{
DecimalNum = Convert.ToInt32(txtInput.Text);
while (DecimalNum > 0)
{
Remainder = DecimalNum % 16;
string hexDigit = (Remainder < 10)
? Remainder.ToString()
: ((char)('A' + Remainder - 10)).ToString();
Result = hexDigit + Result;
DecimalNum /= 16;
}
lblResult.Text = Result;
}
if (ddlSourcePosNum.SelectedIndex == 2 && ddlTargetPosNum.SelectedIndex == 1)
{
BinaryNum = Convert.ToInt32(txtInput.Text, 2);

9
num-converter/WebForm1.aspx.designer.cs

@ -32,15 +32,6 @@ namespace num_converter
/// </remarks>
protected global::System.Web.UI.WebControls.DropDownList ddlSourcePosNum;
/// <summary>
/// Label1 control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label Label1;
/// <summary>
/// ddlTargetPosNum control.
/// </summary>

Loading…
Cancel
Save