Intranet Journal

Go Back   IT Management Forum > Intranet Journal

Intranet Journal The new discussion forum for Intranet Journal readers. Leave comments and questions for IJ authors. Suggest story ideas and provide feedback.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-07-2006, 06:51 AM
busvald busvald is offline
Registered User
 
Join Date: Jun 2006
Posts: 4
How to delete SPACE in value "1 000"

Hi,

I have a situation like this:
I have script which import value from xml file. Then the script transform value into words for example: 100 --> one hundred.

My problem is when the value is bigger then 999 so for example 1 500 there is a SPACE between 1 and 5 and the script can not work correctly.

Do you now how to transform the value with the SPACE into value without SPACE ? Maybe you did something like this beforee.


Regards,

Tom
Reply With Quote
  #2 (permalink)  
Old 06-07-2006, 07:27 AM
JPnyc JPnyc is offline
Administrator
 
Join Date: Jan 2005
Posts: 419
Not without some information. You didn't tell us what language the script is coded in, and you didn't show us the code. Could be anything
__________________
Datamation Online Community Manager

.
Reply With Quote
  #3 (permalink)  
Old 06-07-2006, 09:35 AM
busvald busvald is offline
Registered User
 
Join Date: Jun 2006
Posts: 4
OK, HERE IS A CODE, COMMENTS FOR YOU ARE WITH THE BIG LETTERS


Sub Main(xmlDoc)
Set xmlRoot = xmlDoc.documentElement
Set xmlNode = xmlRoot.ChildNodes(0)
For each xmlPNode in xmlNode.getElementsByTagName("TaxPercentAmounts")
q=xmlPNode.getAttribute("TaxPctExtPWT")

'OK SO NOW "Q" IS VALUE WHICH IS TAKEN FROM XML FILE

x = q

NOW I PUT "Q" (VALUE) AS "X" AND THEN THE REST OF THE SCRIPT DO THE JOB



If (x >= 0 And x <= 1000000) Then

If (x > 99999 And x <= 999999) Then

l6 = Mid(x, 6, 1)
l5 = Mid(x, 5, 1)
l4 = Mid(x, 4, 1)
l3 = Mid(x, 3, 1)
l2 = Mid(x, 2, 1)
l1 = Mid(x, 1, 1)
End If
If (x > 9999 And x <= 99999) Then

l6 = Mid(x, 5, 1)
l5 = Mid(x, 4, 1)
l4 = Mid(x, 3, 1)
l3 = Mid(x, 2, 1)
l2 = Mid(x, 1, 1)
End If
If (x > 999 And x <= 9999) Then

l6 = Mid(x, 4, 1)
l5 = Mid(x, 3, 1)
l4 = Mid(x, 2, 1)
l3 = Mid(x, 1, 1)
End If
If (x > 99 And x <= 999) Then

l6 = Mid(x, 3, 1)
l5 = Mid(x, 2, 1)
l4 = Mid(x, 1, 1)
End If
If (x > 9 And x <= 99) Then

l6 = Mid(x, 2, 1)
l5 = Mid(x, 1, 1)
End If
If (x >= 0 And x <= 9) Then

l6 = Mid(x, 1, 1)
Else
End If
End If
'-----------------------------------------------------------TABLE
Dim jednosci(9)
jednosci(0) = "zero":
jednosci(1) = "jeden":
jednosci(2) = "dwa":
jednosci(3) = "trzy":
jednosci(4) = "cztery":
jednosci(5) = "pięć":
jednosci(6) = "sześć":
jednosci(7) = "siedem":
jednosci(8) = "osiem":
jednosci(9) = "dziewięć"

Dim dz10_19(10)
dz10_19(0) = "dziesięć":
dz10_19(1) = "jedenaście":
dz10_19(2) = "dwanaście":
dz10_19(3) = "trzynaście":
dz10_19(4) = "czternaście":
dz10_19(5) = "piętnaście":
dz10_19(6) = "szesnaście":
dz10_19(7) = "siedemnaście":
dz10_19(8) = "osiemnaście":
dz10_19(9) = "dziewiętnaście"

Dim dz20_90(9)
dz20_90(1) = "":
dz20_90(2) = "dwadzieścia":
dz20_90(3) = "trzydzieści":
dz20_90(4) = "czterdzieści":
dz20_90(5) = "piećdziesiąt":
dz20_90(6) = "sześćdziesiąt":
dz20_90(7) = "siedemdziesiąt":
dz20_90(8) = "osiemdziesiąt":
dz20_90(9) = "dziewięćdziesiąt"

Dim s100_900(9)
s100_900(1) = "sto":
s100_900(2) = "dwieście":
s100_900(3) = "trzysta":
s100_900(4) = "czterysta":
s100_900(5) = "pięćset":
s100_900(6) = "sześćset":
s100_900(7) = "siedemset":
s100_900(8) = "osiemset":
s100_900(9) = "dziewięćset"

Dim tys(3)
tys(0) = "tysiac":
tys(1) = "tysiące":
tys(2) = "tysięcy"

If (l1 = "") Then
wynik6 = ""
ElseIf (l1 >= 1 And l1 <= 9) Then
wynik6 = s100_900(l1) & " "
End If

If (l2 = "") Then
wynik5 = ""
ElseIf (l2 = 0) Then
wynik5 = ""
ElseIf (l2 = 1) Then
wynik5 = dz10_19(l3) & " "
ElseIf (l2 >= 2 And l2 <= 9) Then
wynik5 = dz20_90(l2) & " "
End If

If (l3 = "") Then
wynik4 = ""
ElseIf (l3 = 0) Then
wynik4 = tys(2) & " "
ElseIf (l3 = 1) Then
wynik4 = tys(0) & " "
ElseIf (l3 >= 2 And l3 <= 4) Then
wynik4 = jednosci(l3) & " " & tys(1) & " "
ElseIf (l3 >= 5) Then
wynik4 = jednosci(l3) & " " & tys(2) & " "
End If

wynik3 = s100_900(l4) & " "

If (l5 = 1) Then
wynik2 = dz10_19(l6)
End If
If (l5 > 1 And l6 > 0) Then
wynik2 = dz20_90(l5) & " "
End If
If (l5 > 1 And l6 = 0) Then
wynik2 = dz20_90(l5)
End If

If (l6 = 0) Then
wynik1 = ""
Else
wynik1 = jednosci(l6)
End If

If (x = 1000000) Then
prosty = "milion"
Else If (x = 0) Then prosty = "zero"

End If

wynik_koncowy = wynik6 & wynik5 & wynik4 & wynik3 & wynik2 & wynik1 & prosty & " złotych "


NOW I HAVE THE VALUE IN WORD AND I PUT IT INTO THE XML FILE


xmlPNode.setAttribute "TaxPctExtPWT",wynik_koncowy
Next
xmlDoc.save ("C:\TEST.xml")
End Sub




THE problem is when the "Q" is bigger then 999 in xml the value is with the spaces for example 12 456,00 and when the second part of the script which transform the value meet the space, script is blocked.

I tryed to use something like this

Replace(q, " ", "") but when I run the script there is information that in to the SUB you can not use overriding procedure. What I should do ?
Reply With Quote
  #4 (permalink)  
Old 06-07-2006, 11:02 AM
JPnyc JPnyc is offline
Administrator
 
Join Date: Jan 2005
Posts: 419
Try adding Dim x,q As Integer to your declarations. You didn't declare a datatype and I think it'll default to variable datatype which has unpredictable results.

If that doesn't work we can use a regEx replace to get rid of the space.
__________________
Datamation Online Community Manager

.
Reply With Quote
  #5 (permalink)  
Old 06-08-2006, 05:20 AM
busvald busvald is offline
Registered User
 
Join Date: Jun 2006
Posts: 4
INT fixed the problem,

Thanks for help
Reply With Quote
Reply

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -5. The time now is 04:06 AM.





Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0