|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
i wish to forma the amount entered in atext box(for eg:1500000)
in the indian rupee foramt.ie,like this,15,00,000.as the lakh digit grouping.if its dollar amount then it would ahve been 1,500,000. that funtion is readily available in vb. but how do i make my amount like this? ex: 10000000 1,00,00,000 500000 5,00,000 Plz give me ur suggestions. |
|
#2
|
|||
|
|||
|
I don't know what's u asked!
|
|
#3
|
||||
|
||||
|
this may be complicated. It may require breaking the string into an array of individual characters and then writing them out inside of a loop, using a counter to determine where your commas should be. Another possibility would be to do something like this...
Code:
Private Sub Form_Load()
Dim Money As Double
Dim strMoney As String
Dim charArray() As String
Dim i As Integer
Money = 10000000
strMoney = Trim(Str(Money))
ReDim Preserve charArray(Len(Str(Money)) - 1) As String
MsgBox UBound(charArray)
Mid(strMoney, Len(strMoney) - 3, 1) = ","
i = Len(strMoney) - (3 + 1)
i = i / 2
If i Mod 2 = 0 Then
i = i - 1
End If
Do While i > 0
Mid(strMoney, 2 * i, 1) = ","
i = i - 1
Loop
MsgBox strMoney
End Sub
I haven't tested this on a lot of data, but it works in this case. You can use it as a model though to do something more complicated, if you would like. |
|
#4
|
||||
|
||||
|
nevermind, I just tested that code, and it doesn't work exactly like I wanted. What you will want to do is declare two temporary strings. Find where you want to insert a comma and do the following...
1. Capture the string up to that point in one temp variable. 2. Capture the string after that point in the second temp variable. 3. Concatenate the two strings back together using the & operator and inserting a "," between the two strings storing the value in your original string. 4. After your operations, the original string should contain the format you want. You cannot place this value in a double or integer variable as it will not retain the commas. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Formatting Number |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|