Those pics don't show enough. Copy and paste your code in here, and we'll have a better idea.
tinstaafl
Nearly a Posting Virtuoso
1,321 posts since Jun 2010
Reputation Points: 355
Solved Threads: 228
Skill Endorsements: 14
The only thing I can think of is, if jakar is a number, it will automatically cast a string if the string is numbers only. anything else except for a period and it will thorw an exception
tinstaafl
Nearly a Posting Virtuoso
1,321 posts since Jun 2010
Reputation Points: 355
Solved Threads: 228
Skill Endorsements: 14
Data mismatch error refers to a mismatch of a value returned i.e. if you told the code to return an integer (numbers) but the data returned is a string (letters etc.), the error will be fired.
What did you declare "jarak" as, an integer or a string?
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20
It looks to me that strInput should be concatenated not just assigned. Try this : strInput = strInput & .Input. See if that helps.
tinstaafl
Nearly a Posting Virtuoso
1,321 posts since Jun 2010
Reputation Points: 355
Solved Threads: 228
Skill Endorsements: 14
What is the value of the string to be returned - "the distance : 35 m"?
This will raise an error because jarak should be a number. Remove the "Dim jarak As Integer" and just do "Dim jarak" for testing purposes. If this works, we know where your error is raised.
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20
Also, make sure that you have the Mid sections correctly, including spaces to return just the distance number... "jarak = Mid((Text1.Text), 6, 3)"
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20
One thing to remember with the Mid method the index is 1 based.
tinstaafl
Nearly a Posting Virtuoso
1,321 posts since Jun 2010
Reputation Points: 355
Solved Threads: 228
Skill Endorsements: 14
I think I caught your problem. If I look at your photo, you are setting mid correctly to return from 6. You do however ask to read 3 spaces and not 2 to cover for the 14 of 14 cm. When returning 3 spaces, it returns 14 AND an empty space which will result in an empty data returned value, hence the error. change the 3 to 2 and let me know if that solved the error.
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20
Looking at that string it looks to me that the index for the mid function should be 10 and the length 2
tinstaafl
Nearly a Posting Virtuoso
1,321 posts since Jun 2010
Reputation Points: 355
Solved Threads: 228
Skill Endorsements: 14
If your string follows this format,
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13| 14|
| T | i | n | g | g | i | | : | | x | x | | c | m |
, then you could try this,jarak = Val(Mid(Text1.Text,10,3)). The Val function is a little more forgiving in that it will ignore leading and trailing spaces(i.e. it will process 2 or 3 digit numbers without a problem). Also if it can't parse a number from the string it will return 0 instead of throwing an exception.
tinstaafl
Nearly a Posting Virtuoso
1,321 posts since Jun 2010
Reputation Points: 355
Solved Threads: 228
Skill Endorsements: 14
You can use the Replace function...
jarak = Mid((Text1.Text), 6, 3)
jarak = Replace$(jarak, " ", "")
This will replace all empty spaces IF they exist, else it will remain the same.
AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20
Does strFilter(I) follow the same pattern as Text1.Text? If so the Val function will work for it too. If not it's just a matter of adjusting the parameters of the mid function inside the vall function.
tinstaafl
Nearly a Posting Virtuoso
1,321 posts since Jun 2010
Reputation Points: 355
Solved Threads: 228
Skill Endorsements: 14