Hi, Im new to VB, but and pretty famliar with python. I have some code I need to change from python to VB, to run in an access database. Problem I am running into is I can't slice up my string as I need to.

someString = '12ABC1234512345'
numberString = Mid(someString, 6)

percision = Len(numberString) / 2

begginingHalf = Mid(someString, 6, percison)
endHalf = Right(someString, percision)

The Mid function works exactly as I want it to...but when I try to slice my string with the right function I get run-time error 94, invalid use of null. I debug it, and it says that someString is null, in the Right function. If I run just the Mid function, it works fine. If I remove the Mid function and run just the right function, it still wont work... If I replace percision, with a numeral, 5, for instance, it WILL work...even though the debugger alleges that someString is null. Any ideas?

You have one of your declerations as an integer and not a string. VB6 tries to devide the result by 2 according to your code above, which means the result is 0/2, resulting in an error. If precision is null, write some error code as in -

If precision = 0 Then
'what you want to do here
Else
percision = Len(numberString) / 2
End If

Hope this solved your problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.