IN a line of txt file i get a string similar my_string = mid(....1,2ecc) (are amount )
example:
1.067,491 C
1.067,490 D
in this case i get only the number and not D or C
How to compose automaticlyy the my_string wirth + if the letter i C and - if the letter is D
need this final result:
-1.067,490
+1.067,491
note:
the position of letters are aleways in the position after the number.
i think if the letter is C peraphs the number string not need + if i make a numeric summ or subctraction, or not?
Hope understand me:-)
credit and debit signs
-
- 2StarLounger
- Posts: 148
- Joined: 26 Dec 2010, 18:17
Re: credit and debit signs
Personally, I like to use Split() to parse strings. Example:
Code: Select all
Dim strArray() As String, my_string As String
strArray = Split("1.067,491 D", " ")
If strArray(1) = "C" Then
my_string = "+" & strArray(0)
Else
my_string = "-" & strArray(0)
End If
MsgBox my_string
-
- PlatinumLounger
- Posts: 4473
- Joined: 26 Apr 2010, 17:36
Re: credit and debit signs
Nice... it work perfect!jscher2000 wrote:Personally, I like to use Split() to parse strings. Example:
Code: Select all
Dim strArray() As String, my_string As String strArray = Split("1.067,491 D", " ") If strArray(1) = "C" Then my_string = "+" & strArray(0) Else my_string = "-" & strArray(0) End If MsgBox my_string
Tks.
-
- PlatinumLounger
- Posts: 4473
- Joined: 26 Apr 2010, 17:36
Re: credit and debit signs
jscher2000 wrote:Personally, I like to use Split() to parse strings. Example:
Code: Select all
Dim strArray() As String, my_string As String strArray = Split("1.067,491 D", " ") If strArray(1) = "C" Then my_string = "+" & strArray(0) Else my_string = "-" & strArray(0) End If MsgBox my_string
About this question...
admit i ahev a series of line with - and + value i need to chek when the summ of each this value are Zero, how to check?
example:
line of text =- 30
line of text =- 30
line of text =+ 60
in this case the last line test if the algebric summ of line in top is zero then msgbox("operation tested")
in effetct i can have in text lines:
amount uno 30 d
amount due 30 d
...
tot of.... 60 c
i hope understand me:-)
Last edited by sal21 on 26 Mar 2011, 23:06, edited 1 time in total.
-
- Administrator
- Posts: 79317
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: credit and debit signs
Do you want to add the values from all lines in the text file?
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4473
- Joined: 26 Apr 2010, 17:36
Re: credit and debit signs
no add...HansV wrote:Do you want to add the values from all lines in the text file?
i loop line by line a text file....
-
- Administrator
- Posts: 79317
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: credit and debit signs
Declare a variable of type Currency:
Dim curRunningSum As Currency
When you begin, set it to 0:
curRunningSum = 0
Each time you read a line, add the value from that line:
curRunningSum = curRunningSum + CCur(MyString)
You can then test whether the running sum is 0:
If curRunningSum = 0 Then
...
End If
Dim curRunningSum As Currency
When you begin, set it to 0:
curRunningSum = 0
Each time you read a line, add the value from that line:
curRunningSum = curRunningSum + CCur(MyString)
You can then test whether the running sum is 0:
If curRunningSum = 0 Then
...
End If
Best wishes,
Hans
Hans
-
- PlatinumLounger
- Posts: 4473
- Joined: 26 Apr 2010, 17:36
Re: credit and debit signs
ONLY YOU!!!!!!!!!!!!!HansV wrote:Declare a variable of type Currency:
Dim curRunningSum As Currency
When you begin, set it to 0:
curRunningSum = 0
Each time you read a line, add the value from that line:
curRunningSum = curRunningSum + CCur(MyString)
You can then test whether the running sum is 0:
If curRunningSum = 0 Then
...
End If