N nickysuwandi Member Licensed User Longtime User Mar 8, 2019 #1 I want to generate number automaticly, like example below this 185678941238 185678941239 185678941240 185678941241 185678941242 185678941243 185678941244 185678941245 185678941246 185678941247 This my code Code: Dim strno As String ="185678941238" For intno =0 To 10 If intno>0 Then strno=strno+intno End If Log(intno & ". " & strno) Next but the result like this : Code: 0. 185678941238 1. 1.85678941239E11 2. 1.85678941241E11 3. 1.85678941244E11 4. 1.85678941248E11 5. 1.85678941253E11 6. 1.85678941259E11 7. 1.85678941266E11 8. 1.85678941274E11 9. 1.85678941283E11 10. 1.85678941293E11 Anyone know where is wrong ??, this don't happen when i use only 4 or 5 digit number. Thanks
I want to generate number automaticly, like example below this 185678941238 185678941239 185678941240 185678941241 185678941242 185678941243 185678941244 185678941245 185678941246 185678941247 This my code Code: Dim strno As String ="185678941238" For intno =0 To 10 If intno>0 Then strno=strno+intno End If Log(intno & ". " & strno) Next but the result like this : Code: 0. 185678941238 1. 1.85678941239E11 2. 1.85678941241E11 3. 1.85678941244E11 4. 1.85678941248E11 5. 1.85678941253E11 6. 1.85678941259E11 7. 1.85678941266E11 8. 1.85678941274E11 9. 1.85678941283E11 10. 1.85678941293E11 Anyone know where is wrong ??, this don't happen when i use only 4 or 5 digit number. Thanks
DonManfred Expert Licensed User Longtime User Mar 8, 2019 #2 nickysuwandi said: strno=strno+intno Click to expand... do you want to add intno to strno? Or do you want to concatenate them? Upvote 0
nickysuwandi said: strno=strno+intno Click to expand... do you want to add intno to strno? Or do you want to concatenate them?
N nickysuwandi Member Licensed User Longtime User Mar 8, 2019 #3 DonManfred said: do you want to add intno to strno? Or do you want to concatenate them? Click to expand... i wan to add it Don Manfred, like example above Upvote 0
DonManfred said: do you want to add intno to strno? Or do you want to concatenate them? Click to expand... i wan to add it Don Manfred, like example above
DonManfred Expert Licensed User Longtime User Mar 8, 2019 #4 What is the extecpted result/logoutput? Upvote 0
E emexes Expert Licensed User Longtime User Mar 8, 2019 #5 NumberFormat2 plus keep in mind that doubles only go to 16 decimal places although perhaps the numeric string is actually being cast to a long, but then I wonder why it resorts to e-notation which I though was a floating-point thing Upvote 0
NumberFormat2 plus keep in mind that doubles only go to 16 decimal places although perhaps the numeric string is actually being cast to a long, but then I wonder why it resorts to e-notation which I though was a floating-point thing
N nickysuwandi Member Licensed User Longtime User Mar 8, 2019 #6 DonManfred said: What is the extecpted result/logoutput? Click to expand... like this 185678941238 185678941239 185678941240 185678941241 185678941242 185678941243 185678941244 185678941245 185678941246 185678941247 Upvote 0
DonManfred said: What is the extecpted result/logoutput? Click to expand... like this 185678941238 185678941239 185678941240 185678941241 185678941242 185678941243 185678941244 185678941245 185678941246 185678941247
E emexes Expert Licensed User Longtime User Mar 8, 2019 #7 If you only ever increment by 1, then you can increment strno without conversion to numeric type and back. I use this when doing variable-length binary or octal or hexadecimal or alphabetical sequences. Upvote 0
If you only ever increment by 1, then you can increment strno without conversion to numeric type and back. I use this when doing variable-length binary or octal or hexadecimal or alphabetical sequences.
E emexes Expert Licensed User Longtime User Mar 8, 2019 #8 nickysuwandi said: like this 185678941238 185678941239 185678941240 185678941241 185678941242 185678941243 185678941244 185678941245 185678941246 185678941247 Click to expand... That doesn't quite match your code sample, where eg the increment is increasing, but I think anyway that your immediate problem is more like: how to get rid of the E-notation eg E+11 Last edited: Mar 8, 2019 Upvote 0
nickysuwandi said: like this 185678941238 185678941239 185678941240 185678941241 185678941242 185678941243 185678941244 185678941245 185678941246 185678941247 Click to expand... That doesn't quite match your code sample, where eg the increment is increasing, but I think anyway that your immediate problem is more like: how to get rid of the E-notation eg E+11
E emexes Expert Licensed User Longtime User Mar 8, 2019 #9 Try this: Code: Dim strno As String = "185678941238" For intno = 0 To 10 If intno > 0 Then strno = NumberFormat2((strno + intno), 1, 0, 0, False) End If Log(intno & ". " & strno) Next Last edited: Mar 8, 2019 Upvote 0
Try this: Code: Dim strno As String = "185678941238" For intno = 0 To 10 If intno > 0 Then strno = NumberFormat2((strno + intno), 1, 0, 0, False) End If Log(intno & ". " & strno) Next
E emexes Expert Licensed User Longtime User Mar 8, 2019 #10 And if that skips a bit because it's maybe still going through the E-notation wringer somewhere, try: Code: Dim strno As String = "185678941238" For intno = 0 To 10 If intno > 0 Then dim L as long = strno L = L + intno strno = L 'or if you still get E-notation, try: strno = NumberFormat2(L, 1, 0, 0, False) End If Log(intno & ". " & strno) Next Upvote 0
And if that skips a bit because it's maybe still going through the E-notation wringer somewhere, try: Code: Dim strno As String = "185678941238" For intno = 0 To 10 If intno > 0 Then dim L as long = strno L = L + intno strno = L 'or if you still get E-notation, try: strno = NumberFormat2(L, 1, 0, 0, False) End If Log(intno & ". " & strno) Next
E emexes Expert Licensed User Longtime User Mar 8, 2019 #11 Of course, that begs the question of: why not just store that long (integer) number As Long rather As String? Upvote 0
Of course, that begs the question of: why not just store that long (integer) number As Long rather As String?
klaus Expert Licensed User Longtime User Mar 8, 2019 #12 Twp problems: 1. The scientific notation. 2. He adds 1,2,3,4 etc instead of 1 !!! Try this: Dim strno As String ="185678941238" For intno = 0 To 9 If intno > 0 Then strno = NumberFormat2((strno + 1), 1, 0, 0, False) End If Log(intno & ". " & strno) Next Or with the Long variable type. Upvote 0
Twp problems: 1. The scientific notation. 2. He adds 1,2,3,4 etc instead of 1 !!! Try this: Dim strno As String ="185678941238" For intno = 0 To 9 If intno > 0 Then strno = NumberFormat2((strno + 1), 1, 0, 0, False) End If Log(intno & ". " & strno) Next Or with the Long variable type.
N nickysuwandi Member Licensed User Longtime User Mar 8, 2019 #13 Thanks Emexes and Klaus for the solutions and explaination Upvote 0