|
-
Dec 11th, 2012, 03:49 PM
#1
Thread Starter
Lively Member
[RESOLVED] breaking amout
Dear All,
Good Day,
I am using VB6, I have a Issue Breaking Amount in Chunk of 1,000,000/-
Case 1 - Suppose my amount is 1,500,000/- then it should break in 1st amount = 1,000,000/- & 2nd 500,000/-
Case 2 - Suppose my amount is 3,000,100/- then it should break in 1st amount = 1,000,000/- & 2nd 1000,000/- 3rd 1000,000/- & 4th 100/-
I have used function mode but it is working randomly!
Please assist
Thanks
-
Dec 11th, 2012, 04:25 PM
#2
Re: breaking amout
Post your algorithm and we'll try to debug it for you.
-
Dec 11th, 2012, 04:37 PM
#3
Thread Starter
Lively Member
Re: breaking amout
i am using input from a excel file, pasting the extract of it
basically i have to break the Amount & Save in Access database
Insert & Excel File modules are working fine, issue is with Breaking Values through Mode, this Code is working fine randomly, sometimes it skip the values & sometimes it return/insert 0 as amount
Code:
If Val(rsExcel("Amount")) > "1000000" Then
temp_amount = Val(rsExcel("Amount"))
Call InsertValues(1000000)
tcount = Round(Val(rsExcel("Amount")) / 1000000, 0)
temp_remaining = Val(rsExcel("Amount")) Mod 1000000
For i = 1 To tcount - 1
Call InsertValues(temp_remaining)
Next
End if
-
Dec 11th, 2012, 05:00 PM
#4
Thread Starter
Lively Member
Re: breaking amout
Please also note, there will be values which are less then 1M (1,000,000/-) & will not be break
only values above 1M will be beaked
Thanks
-
Dec 11th, 2012, 05:52 PM
#5
Re: breaking amout
First off, your IF statement is wrong....you are tying to compare a value (numeric) with a string ("1000000")
I'll look at the rest in a moment
-
Dec 11th, 2012, 06:05 PM
#6
Re: breaking amout
Looks strange.
Say Amount is 5,500,000
Your first call would input 1000000
Then t_count would be 5 (correct?)
Then, you next calls in your loop would put the SAME value (temp_value) in 5 times.
What you want, I think, is 1000000 put in 5 times and 500,000 put in once. Also correct?
On my iPad so can't experiment, but if my logic is correct, do your loop based on t_count, but put in 10000000, that number of times, and THEN, after the loop, put in temp_remaining once
-
Dec 11th, 2012, 06:06 PM
#7
Re: breaking amout
Someone will solve this for you, if you don't, before I can get to my pc.
-
Dec 11th, 2012, 06:10 PM
#8
Thread Starter
Lively Member
Re: breaking amout
as i mention b4 its working randomly...
is there any alternative way to do this pls
Thanks
-
Dec 11th, 2012, 08:18 PM
#9
Re: breaking amout
Did you change your IF statement to look at 1000000, versus "10000000"?
-
Dec 12th, 2012, 04:17 AM
#10
Member
Re: breaking amout
try this:
Code:
While temp_amount > 1000000
'will loop for each chunk of 1,000,000
temp_amount = temp_amount - 1000000
wend
'process the last chunk
-
Dec 12th, 2012, 10:57 AM
#11
Thread Starter
Lively Member
Re: breaking amout
HEllo Welshman & SamOscarBrown
Welshman
i have tested your code, actually i want to break the amount in part but each part should not be more then 1,000,000/- as per ur code its decreasing the amount but the value is more then 1,000,000/-
looking for help
-
Dec 12th, 2012, 11:08 AM
#12
Thread Starter
Lively Member
Re: breaking amout
Thanks alot all
i have fixed it
gr8!
-
Dec 12th, 2012, 11:22 AM
#13
Re: [RESOLVED] breaking amout
Code:
Const CHUNK = 1000000#
Dim temp_amount As Double, i As Long
temp_amount = Val(rsExcel("Amount"))
If temp_amount > CHUNK Then
For i = 1& To temp_amount \ CHUNK
Call InsertValues(CHUNK)
Next
End If
Call InsertValues(temp_amount Mod CHUNK)
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|