An error occurred when I Run my form, what does the following error mean?
(refer to screenshot)
thks,
FYRe
Printable View
An error occurred when I Run my form, what does the following error mean?
(refer to screenshot)
thks,
FYRe
your trying to pass a value of string in datatype integer.
Post the code and well help you convert it. ;)
Edit: Congrats Mar_Zim on 1,000 posts! :thumb: You should mark this post so you can refer back to it in the years to come :D
Well thanks guys and congrats robdog888 of your new power. I've heard rumors that some mod's got jealous because of your status.:D
abt posting the codes... i guess not, it's very long & messy. Maybe I'll just send a screenshot. Will that do?
Just post the line that you pass the value "Pa" or toggle then post the code on where it throws an exception.
Find the code where it shows the "PA" and post those lines and that should help. you could also just step through your code by pressing F11 (default) or F8 if you set it as the VB6 classic IDE interface. Then you can step and find the exact line of offensive code. ;)
Thanks for the congrats mar_zim and I dont think there were any issues with it. ;) Everything is running smooth as could be.
Ps, by tomorrow night I should hit 18K posts :D
Ok, my form contain this browse button, so when user clicks on it, it opens an OpenFileDialog.
" Extract_Number " extracts the digits of a particular filename.
For example if I have the following as my filename:
" C:\Documents and Settings\user\Desktop\033227D - Pattern Matching\ATTOS chips\chips-005.bmp ",
it will extract the number 5 from 005.
so,
if 006, extracts 6
if 007, extracts 7
if 008, extracts 8
if 009, extracts 9
if 010, extracts 10
etc.....
however, when I Run my form, the error occured as shown in screenshot.
thks,
FYRe
oh man, why does the uploaded images does not show?
The error is because your parsing on the first dash "- Pattern Matching\ATTOS chips\chips-005.bmp" and thats giving you a return of "Pa". ;)
You have 2 instances of the dash. ;)
If you attach 2 or more images the image shows as a link. Just click on the link file. ;)
You could use instrrev instead so you start your search for the dash from the end (right side to left side) and catch the last occurance of the dash. ;)
VB Code:
'something like this... intPos = InStrRev(strBuff, "-") + 1
hold on.... i'm checkin' it out...
As what I've understand the ImageNumber is an integer then the Extract_Number is a string then you assign the ImageNumber to the function string which is wrong.
Try to cast your function Extract_Number to int. ImageNumber=CInt(Extract_Number(OpenfileDialog1.FileName)
So, do I replace all my IntStr to InStrRev ?Quote:
Originally Posted by RobDog888
So, you're trying to say that InStrRev( ) , search for the dash from right-to-left,
and IntStr( ) search for the dash from left-to-right ?
No, more like search for the dash from right to left and search for the dot from right to left. This will always give you the last occurance of the chars so if the filepath has those chars it wont interfere with your code parsing. ;)
I'll see if I can come up with some .NET code for you. ;)
How about something like:VB Code:
Dim fileName As String = "C:\Documents and Settings\user\Desktop\033227D - Pattern Matching\ATTOS chips\chips-005.bmp fileName = IO.Path.GetFileNameWithoutExtension(fileName) Dim fileNumber As Integer = Integer.Parse(fileName.Substring(fileName.LastIndexOf("-"c) + 1))
I step away for a minute helping in another thread and wham! There it is. :lol:
Good job John. :thumb:
I want to declare an integer variable, "MatchesFound", and this integer variable contains an integer. I want the value to be able to use in my another form. What should I declare it as ?
Public ? Friend ?
I'd suggest you use a Private, class-level variable and a Public ReadOnly property that returns that variable:VB Code:
Private m_MatchesFound As Integer Public ReadOnly Property MatchesFound() As Integer Get Return Me.m_MatchesFound End Get End Property
Jm, do I have to declare m_MatchesFound in both forms?
I'll post this question in another thread... Anyway, thks for the solutions.
m_MatchesFound is a variable private to the class it's being calculated in. You then access it's value from outside that class via the MatchesFound property.Quote:
Originally Posted by FYRe
Just one very small stylistic point. MatchesFound sounds like a boolean variable to me. If a variable is meant to be counting something then it's a good idea to reflect that in the name, e.g. MatchCount or NumMatches. Like I said, a very small point but I'm a bit uptight that way. :)