Hi zulkarnain,
I have created a sample. Refer the below code.
HTML
<table>
<tr>
<td>
Crore:
<asp:DropDownList ID="ddlCrore" runat="server">
<asp:ListItem Text="Select" Value="-1" />
<asp:ListItem Text="0" Value="0"></asp:ListItem>
<asp:ListItem Text="1" Value="1"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
<asp:ListItem Text="5" Value="5"></asp:ListItem>
<asp:ListItem Text="6" Value="6"></asp:ListItem>
<asp:ListItem Text="7" Value="7"></asp:ListItem>
<asp:ListItem Text="8" Value="8"></asp:ListItem>
<asp:ListItem Text="9" Value="9"></asp:ListItem>
<asp:ListItem Text="10" Value="10"></asp:ListItem>
<asp:ListItem Text="11" Value="11"></asp:ListItem>
<asp:ListItem Text="12" Value="12"></asp:ListItem>
<asp:ListItem Text="13" Value="13"></asp:ListItem>
<asp:ListItem Text="14" Value="14"></asp:ListItem>
<asp:ListItem Text="15" Value="15"></asp:ListItem>
<asp:ListItem Text="16" Value="16"></asp:ListItem>
<asp:ListItem Text="17" Value="17"></asp:ListItem>
<asp:ListItem Text="18" Value="18"></asp:ListItem>
<asp:ListItem Text="19" Value="19"></asp:ListItem>
<asp:ListItem Text="20" Value="20"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
Lakh:
<asp:DropDownList ID="ddlLac" runat="server">
<asp:ListItem Text="Select" Value="-1" />
<asp:ListItem Text="0" Value="0"></asp:ListItem>
<asp:ListItem Text="1" Value="1"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
<asp:ListItem Text="5" Value="5"></asp:ListItem>
<asp:ListItem Text="6" Value="6"></asp:ListItem>
<asp:ListItem Text="7" Value="7"></asp:ListItem>
<asp:ListItem Text="8" Value="8"></asp:ListItem>
<asp:ListItem Text="9" Value="9"></asp:ListItem>
<asp:ListItem Text="10" Value="10"></asp:ListItem>
<asp:ListItem Text="11" Value="11"></asp:ListItem>
<asp:ListItem Text="12" Value="12"></asp:ListItem>
<asp:ListItem Text="13" Value="13"></asp:ListItem>
<asp:ListItem Text="14" Value="14"></asp:ListItem>
<asp:ListItem Text="15" Value="15"></asp:ListItem>
<asp:ListItem Text="16" Value="16"></asp:ListItem>
<asp:ListItem Text="17" Value="17"></asp:ListItem>
<asp:ListItem Text="18" Value="18"></asp:ListItem>
<asp:ListItem Text="19" Value="19"></asp:ListItem>
<asp:ListItem Text="20" Value="20"></asp:ListItem>
</asp:DropDownList>
</td>
<td>
Thousand
<asp:DropDownList ID="ddlThousand" runat="server">
<asp:ListItem Text="Select" Value="-1" />
<asp:ListItem Text="0" Value="0"></asp:ListItem>
<asp:ListItem Text="1" Value="1"></asp:ListItem>
<asp:ListItem Text="2" Value="2"></asp:ListItem>
<asp:ListItem Text="3" Value="3"></asp:ListItem>
<asp:ListItem Text="4" Value="4"></asp:ListItem>
<asp:ListItem Text="5" Value="5"></asp:ListItem>
<asp:ListItem Text="6" Value="6"></asp:ListItem>
<asp:ListItem Text="7" Value="7"></asp:ListItem>
<asp:ListItem Text="8" Value="8"></asp:ListItem>
<asp:ListItem Text="9" Value="9"></asp:ListItem>
<asp:ListItem Text="10" Value="10"></asp:ListItem>
<asp:ListItem Text="11" Value="11"></asp:ListItem>
<asp:ListItem Text="12" Value="12"></asp:ListItem>
<asp:ListItem Text="13" Value="13"></asp:ListItem>
<asp:ListItem Text="14" Value="14"></asp:ListItem>
<asp:ListItem Text="15" Value="15"></asp:ListItem>
<asp:ListItem Text="16" Value="16"></asp:ListItem>
<asp:ListItem Text="17" Value="17"></asp:ListItem>
<asp:ListItem Text="18" Value="18"></asp:ListItem>
<asp:ListItem Text="19" Value="19"></asp:ListItem>
<asp:ListItem Text="20" Value="20"></asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
<asp:Button ID="Button1" Text="Calculate" runat="server" OnClick="Calculate" />
</td>
<td colspan="2">
<asp:TextBox runat="server" ID="txtValue" />
</td>
</tr>
</table>
C#
protected void Calculate(object sender, EventArgs e)
{
if (ddlCrore.SelectedValue != "-1" && ddlLac.SelectedValue != "-1" && ddlThousand.SelectedValue != "-1")
{
string crore = ToLong(ddlCrore.SelectedItem.Text.Trim() + " 10000000").ToString();
string lac = ToLong(ddlLac.SelectedItem.Text.Trim() + " 100000").ToString();
string thousand = ToLong(ddlThousand.SelectedItem.Text.Trim() + " 1000").ToString();
txtValue.Text = (Convert.ToDecimal(crore) + Convert.ToDecimal(lac) + Convert.ToDecimal(thousand))
.ToString("N0", System.Globalization.CultureInfo.CreateSpecificCulture("hi-IN"));
}
}
private static Dictionary<string, long> numberTable = new Dictionary<string, long> {
{"0",0},{"1",1},{"2",2},{"3",3},{"4",4},
{"5",5},{"6",6},{"7",7},{"8",8},{"9",9},
{"10",10},{"11",11},{"12",12},{"13",13},
{"14",14},{"15",15},{"16",16},
{"17",17},{"18",18},{"19",19},{"20",20},
{"30",30},{"40",40},{"50",50},{"60",60},
{"70",70},{"80",80},{"90",90},{"100",100},
{"1000",1000},{"100000",100000},{"10000000",10000000}};
public static long ToLong(string numberString)
{
var numbers = Regex.Matches(numberString, @"\w+").Cast<Match>()
.Select(m => m.Value.ToLowerInvariant())
.Where(v => numberTable.ContainsKey(v))
.Select(v => numberTable[v]);
long acc = 0, total = 0L;
foreach (long n in numbers)
{
if (n >= 1000)
{
total += (acc * n);
acc = 0;
}
else if (n >= 100)
{
acc *= n;
}
else acc += n;
}
return (total + acc) * (numberString.StartsWith("minus", StringComparison.InvariantCultureIgnoreCase) ? -1 : 1);
}
VB.Net
Protected Sub Calculate(sender As Object, e As EventArgs)
If ddlCrore.SelectedValue <> "-1" AndAlso ddlLac.SelectedValue <> "-1" AndAlso ddlThousand.SelectedValue <> "-1" Then
Dim crore As String = ToLong(ddlCrore.SelectedValue.Trim() + " 10000000").ToString()
Dim lac As String = ToLong(ddlLac.SelectedValue.Trim() + " 100000").ToString()
Dim thousand As String = ToLong(ddlThousand.SelectedValue.Trim() + " 1000").ToString()
txtValue.Text = (Convert.ToDecimal(crore) + Convert.ToDecimal(lac) + Convert.ToDecimal(thousand)).ToString("N0", System.Globalization.CultureInfo.CreateSpecificCulture("hi-IN"))
End If
End Sub
Private Shared numberTable As New Dictionary(Of String, Long)() From { _
{"0", 0}, {"1", 1}, {"2", 2}, {"3", 3}, {"4", 4}, {"5", 5}, {"6", 6}, {"7", 7}, {"8", 8}, {"9", 9}, {"10", 10}, _
{"11", 11}, {"12", 12}, {"13", 13}, {"14", 14}, {"15", 15}, {"16", 16}, {"17", 17}, {"18", 18}, {"19", 19}, {"20", 20}, _
{"30", 30}, {"40", 40}, {"50", 50}, {"60", 60}, {"70", 70}, {"80", 80}, {"90", 90}, {"100", 100}, _
{"1000", 1000}, {"100000", 100000}, {"10000000", 10000000}
}
Public Shared Function ToLong(numberString As String) As Long
Dim numbers = Regex.Matches(numberString, "\w+").Cast(Of Match)() _
.[Select](Function(m) m.Value.ToLowerInvariant()) _
.Where(Function(v) numberTable.ContainsKey(v)) _
.[Select](Function(v) numberTable(v))
Dim acc As Long = 0, total As Long = 0L
For Each n As Long In numbers
If n >= 1000 Then
total += (acc * n)
acc = 0
ElseIf n >= 100 Then
acc *= n
Else
acc += n
End If
Next
Return (total + acc) * (If(numberString.StartsWith("minus", StringComparison.InvariantCultureIgnoreCase), -1, 1))
End Function
Screenshot

Note: You need to change the code as per your requirement and add numbers in the numberTable Dictionary.