Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 13th, 2004, 05:12 AM
la2004 la2004 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 1 la2004 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Formatting Number

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.

Reply With Quote
  #2  
Old January 13th, 2004, 08:04 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
I don't know what's u asked!

Reply With Quote
  #3  
Old January 13th, 2004, 09:25 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,194 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 57 m 32 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
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.

Reply With Quote
  #4  
Old January 13th, 2004, 09:32 AM
Fisherman's Avatar
Fisherman Fisherman is offline
Inherits Programmer.Slacker
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Aug 2003
Location: Between my Id and your Ego
Posts: 2,194 Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level)Fisherman User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 13 h 57 m 32 sec
Reputation Power: 142
Send a message via ICQ to Fisherman Send a message via AIM to Fisherman
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Formatting Number


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT