David R
I know a few things...
- Local time
- Today, 08:40
- Joined
- Oct 23, 2001
- Messages
- 2,632
I've used OOP before and some VBA lately, but I'm still not sure how to create a function from the raw ether.
I want to take a street address and return merely the city block, i.e. 2412 Main St. becomes 2400 Main St. Apartments are always delimited by commas, i.e. 12402 Maple Dr., Apt. 101 becomes 12400 Maple Dr.
I can do this in a query, however the two different cases perplex me. Here's what I have so far:
Public Function BlockLocator(OriginalAddress As String)
Dim varLocation, varL1, varL2 As String
Dim varS, varS1, varS2 As String
If IsNull(OriginalAddress) Then End Function
varS = Len([OriginalAddress])
varS1 = InStr(0, [OriginalAddress], " ")
varL1 = Left([OriginalAddress], varS1 - 3)
varL2 = Right([OriginalAddress], varS - varS1)
varS2 = InStr(0, varL2, ",", 1)
If (varS2 > 1) Then End Function
If (varS2 = 1) Then varL2 = Left(varL2, varS2 - 1)
varLocation = varL1 + "00 " + varL2
BlockLocator = varLocation
End Function
How do I debug test this? In theory it's going to become part of an SQL query so that I can interface with the police blotter.
I want to take a street address and return merely the city block, i.e. 2412 Main St. becomes 2400 Main St. Apartments are always delimited by commas, i.e. 12402 Maple Dr., Apt. 101 becomes 12400 Maple Dr.
I can do this in a query, however the two different cases perplex me. Here's what I have so far:
Public Function BlockLocator(OriginalAddress As String)
Dim varLocation, varL1, varL2 As String
Dim varS, varS1, varS2 As String
If IsNull(OriginalAddress) Then End Function
varS = Len([OriginalAddress])
varS1 = InStr(0, [OriginalAddress], " ")
varL1 = Left([OriginalAddress], varS1 - 3)
varL2 = Right([OriginalAddress], varS - varS1)
varS2 = InStr(0, varL2, ",", 1)
If (varS2 > 1) Then End Function
If (varS2 = 1) Then varL2 = Left(varL2, varS2 - 1)
varLocation = varL1 + "00 " + varL2
BlockLocator = varLocation
End Function
How do I debug test this? In theory it's going to become part of an SQL query so that I can interface with the police blotter.