-
Oct 14th, 2019, 12:35 PM
#1
Thread Starter
Member
[RESOLVED] VBA error
Hello,
I am a new in VBA and I am facing the attached error. I would appreciate any help. Thanks in advance
-
Oct 14th, 2019, 12:46 PM
#2
Re: VBA error
This forum makes screen captures hard to read. Post the code (enclosed in code tags) and the text of the error message. Add a comment to the line causing the error so we can diagnose the issue.
-
Oct 14th, 2019, 01:11 PM
#3
Thread Starter
Member
Re: VBA error
Thank you for the prompt reply. I would like to inform you that the code is enough big. The error happens in 390 line
-
Oct 14th, 2019, 01:14 PM
#4
Thread Starter
Member
-
Oct 14th, 2019, 01:16 PM
#5
Re: VBA error
I would like to inform you that the code is enough big. The error happens in 390 line.
We have no idea what this means. Also, there are no line numbers in the screen capture, so 'line 390' is not helpful. We also still do not know what the error message you are getting is. Post at least the error message text and the line of code that is highlighted as the cause of the error.
-
Oct 14th, 2019, 01:21 PM
#6
Thread Starter
Member
Re: VBA error
For the first run, EPIC rewrite output
Input #2, X, Y, DEM, Slope, Landuse, Soil, Climate, Country, FER, MaxIrr . 390 line of the code is appearing.
Thank you.
Last edited by getziatz; Nov 2nd, 2020 at 10:41 AM.
-
Oct 14th, 2019, 01:23 PM
#7
Thread Starter
Member
Re: VBA error
Input #2, X, Y, DEM, Slope, Landuse, Soil, Climate, Country, FER, MaxIrr . 390 line of the code, the error is appearing.
Thank you.
Last edited by getziatz; Nov 2nd, 2020 at 10:41 AM.
-
Oct 14th, 2019, 01:24 PM
#8
Thread Starter
Member
Re: VBA error
I am really sorry.
Input #2, X, Y, DEM, Slope, Landuse, Soil, Climate, Country, FER, MaxIrr (In 390 line of the code, this error is appearing)
-
Oct 14th, 2019, 01:25 PM
#9
Thread Starter
Member
Re: VBA error
I am really sorry.
Input #2, X, Y, DEM, Slope, Landuse, Soil, Climate, Country, FER, MaxIrr (In 390 line of the code, this error is appearing)
-
Oct 14th, 2019, 01:37 PM
#10
Re: VBA error
OK, now we have the line of code where the error is occurring. That gives us some ideas as to what possible errors can occur. However, we still do not know exactly what the error message is. Post that information. It should be something like "run-time error 13 – Type mismatch". Once we know what the error message that YOU are getting is, we can suggest some ideas as to a possible cause.
-
Oct 14th, 2019, 01:39 PM
#11
Thread Starter
Member
Re: VBA error
run time error ''6" : Overflow
Thank you
-
Oct 14th, 2019, 01:49 PM
#12
Thread Starter
Member
Re: VBA error
run time error ''6" : Overflow
Thank you
-
Oct 14th, 2019, 02:05 PM
#13
Re: VBA error
An overflow error may indicate that you are attempting to store a value that is too large in one of the variables you have defined. Since we cannot see your "Dim" statements, it is hard to say which one. You should have some "Dim" statements in your code. If so, post them. If not, add "Option Explicit" as the first line of your code. You will then get different errors until you properly Dimension your variables.
-
Oct 14th, 2019, 02:20 PM
#14
Thread Starter
Member
Re: VBA error
Thank you. I have a lot of Dim" statements in your code. This is the last "Dim" before the mistake but there are also plenty of "Dim" before the posted one
Dim pProDlgFact As IProgressDialogFactory
Dim pStepPro As IStepProgressor
Dim pProDlg As IProgressDialog2
Dim ptrkCan As ITrackCancel
Set ptrkCan = New CancelTracker
Set pProDlgFact = New ProgressDialogFactory
Set pProDlg = pProDlgFact.Create(ptrkCan, Application.hWnd)
pProDlg.CancelEnabled = True
pProDlg.Title = "Prepare running for Each Grid..."
pProDlg.Animation = esriProgressGlobe
Set pStepPro = pProDlg
pStepPro.MinRange = 1
pStepPro.MaxRange = TotCellNo - 1
pStepPro.StepValue = 1
-
Oct 14th, 2019, 02:24 PM
#15
Thread Starter
Member
Re: VBA error
Thank you. I have a lot of Dim" statements in your code. This is the last "Dim" before the mistake but there are also plenty of "Dim" before the posted one
Dim pProDlgFact As IProgressDialogFactory
Dim pStepPro As IStepProgressor
Dim pProDlg As IProgressDialog2
Dim ptrkCan As ITrackCancel
Set ptrkCan = New CancelTracker
Set pProDlgFact = New ProgressDialogFactory
Set pProDlg = pProDlgFact.Create(ptrkCan, Application.hWnd)
pProDlg.CancelEnabled = True
pProDlg.Title = "Prepare running for Each Grid..."
pProDlg.Animation = esriProgressGlobe
Set pStepPro = pProDlg
pStepPro.MinRange = 1
pStepPro.MaxRange = TotCellNo - 1
pStepPro.StepValue = 1
-
Oct 14th, 2019, 02:27 PM
#16
Re: VBA error
The Dim statements we need to see are the ones for the variables in the line that is causing the error:
Code:
Dim X As ????
Dim Y As ????
Dim DEM As ????
Dim Slope As ????
Dim Landuse As ????
Dim Soil As ????
Dim Climate As ????
Dim Country As ????
Dim FER As ????
Dim MaxIrr As ????
-
Oct 14th, 2019, 02:42 PM
#17
Thread Starter
Member
Re: VBA error
Dim DEM As Integer
Dim Slope As Integer
Dim s As Single
Dim Landuse As Integer
Dim Soil As Integer
Dim Climate As Long
Dim IRR As Integer
Dim Area As Integer
Dim Country As Integer
'Dim FER As Integer
Dim MaxIrr As Integer
Dim ColNo As Integer
Dim RowNo As Integer
-
Oct 14th, 2019, 02:43 PM
#18
Thread Starter
Member
Re: VBA error
Dim DEM As Integer
Dim Slope As Integer
Dim s As Single
Dim Landuse As Integer
Dim Soil As Integer
Dim Climate As Long
Dim IRR As Integer
Dim Area As Integer
Dim Country As Integer
'Dim FER As Integer
Dim MaxIrr As Integer
Dim ColNo As Integer
Dim RowNo As Integer
-
Oct 14th, 2019, 03:00 PM
#19
Re: VBA error
It looks like most of your variables are Integers. Those have a maximum value range of -32,768 to 32,767. If the values you are trying to Input into them are outside that range, you will get the error you are seeing. Try changing them to Long variables to see what happens.
-
Oct 14th, 2019, 03:09 PM
#20
Thread Starter
Member
Re: VBA error
I am putting values from 22.5052688843893 to 39.565108042713
-
Oct 14th, 2019, 03:17 PM
#21
Re: VBA error
longs and integers can only hold whole numbers,
looks like the values should be doubles, but variants would work too
try to avoid double posting, it is a fault in the forum that has never been fixed, when you get the error page that says you have to wait 30 seconds, just click back to the thread or the forum, don't click to post again
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 14th, 2019, 03:20 PM
#22
Thread Starter
Member
Re: VBA error
i do not understand this post
-
Oct 14th, 2019, 03:34 PM
#23
Re: VBA error
For the Dim issue:
Example:
For the double post issue, only click once on the Post Quick Reply, or click Go Advanced and then click Post.
-
Oct 14th, 2019, 03:34 PM
#24
Re: VBA error
i do not understand this post
which parts in particular?
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 14th, 2019, 03:37 PM
#25
Thread Starter
Member
Re: VBA error
this part looks like the values should be doubles, but variants would work too
as well as the last note I do my best.........
-
Oct 14th, 2019, 03:50 PM
#26
Thread Starter
Member
Re: VBA error
this part looks like the values should be doubles, but variants would work too
as well as the last part I do my best.........
-
Oct 14th, 2019, 03:52 PM
#27
Thread Starter
Member
Re: VBA error
sorry the double post now posted accidentally
-
Oct 15th, 2019, 04:52 AM
#28
Re: VBA error
the first part indicates that the values returned from the file would most likely be doubles, so the variables to contain them should be a double, but that you could alternatively use a variant variable, which can contain any type of value, if you are unsure what type of value will be returned, you can use a variant, or when you know what type the variant contains, can later change to that type
the second part is just in my signature, for when i post code samples, without showing the variable dimensions in the extract
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Oct 15th, 2019, 08:08 AM
#29
Thread Starter
Member
Re: VBA error
Changing Dim as Double seems to work. Thank you from the bottom of my heart for your help
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
|