Hi nauna,
Check this example. Now please take its reference and correct your code.
HTML
Allowed(GB):<asp:TextBox runat="server" ID="txtAllowed" /><br />
Consumed(KB):<asp:TextBox runat="server" ID="txtConsumed" /><br />
<asp:Button Text="Calculate" runat="server" OnClick="OnCalculate" /><br />
<asp:Label ID="lblBalance" runat="server" />
Code
C#
protected void OnCalculate(object sender, EventArgs e)
{
double allowed = Convert.ToDouble(txtAllowed.Text.Trim());
double consumed = Convert.ToDouble(txtConsumed.Text.Trim());
double allowedKB = allowed * 1024 * 1024;
double remaining = allowedKB - consumed;
lblBalance.Text = "Remaining " + Math.Round(remaining, 3) +
" KB.<br />Remaining " + Math.Round((remaining / 1024 / 1024), 3) + " GB.";
}
VB.Net
Protected Sub OnCalculate(ByVal sender As Object, ByVal e As EventArgs)
Dim allowed As Double = Convert.ToDouble(txtAllowed.Text.Trim())
Dim consumed As Double = Convert.ToDouble(txtConsumed.Text.Trim())
Dim allowedKB As Double = allowed * 1024 * 1024
Dim remaining As Double = allowedKB - consumed
lblBalance.Text = "Remaining " & Math.Round(remaining, 3) &
" KB.<br />Remaining " & Math.Round((remaining / 1024 / 1024), 3) & " GB."
End Sub
Screenshot