我正尝试通过GeoFire查找用户,由于某种原因,此语法不适用于我。...
Dim myDir As String, fn As String, ws As Worksheet, r As Range
Dim a(), n As Long, x As Long, myTask As String, ff As String, temp
myDir = Range("P2").Value
Debug.Print Range("P2").Value
If Dir(myDir, 16) = "" Then
MsgBox "No such folder path", 64, myDir
Exit Sub
End If
myTask = InputBox("Enter Search String * accepted")
If myTask = "" Then Exit Sub
x = Columns.Count ' <---- Active worksheet count of all columns
fn = Dir(myDir & "*.xls*")
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Do While fn <> ""
With Workbooks.Open(myDir & fn, 0)
For Each ws In .Worksheets ' <- ws is worksheet object ws.Name to return current search worksheet
Set r = ws.Cells.Find(myTask, , , 1) ' <- Actual find return cells address or Nothing object if not found
If Not r Is Nothing Then
ff = r.Address '<- Address of cell where the search was matched
Do
n = n + 1
temp = r.EntireRow.Value ' <- take entire row if the cell was found
ReDim Preserve temp(1 To 1, 1 To x) ' <- preserve temp data i dynamic array basically one dimensional array of cells, which will become a item in array a
ReDim Preserve a(1 To n)
a(n) = temp '<- insert temp array as item in array a
Set r = ws.Cells.FindNext(r) '<- after finding first mach in the worksheet check if later there is something to matching
Loop While ff <> r.Address '<- loop through worksheet until we come back to the cell address we initially found
End If
Next
.Close False
End With
fn = Dir
Loop
With ThisWorkbook.Sheets("IP_Info").Rows(1)
.CurrentRegion.ClearContents
If n > 0 Then
.Resize(n).Value = _
Application.Transpose(Application.Transpose(a))
Else
MsgBox "Not found", , myTask
End If
End With
给我一个错误的“歧义使用'观察者'”
答案 0 :(得分:0)
这对我有用:
func findUsers () {
guard let userLat = userDefault.value(forKey: "current_location_latitude") as? String, let userLong = userDefault.value(forKey: "current_location_longitude") as? String else {return}
let location: CLLocation = CLLocation(latitude: CLLocationDegrees(Double(userLat)!), longitude: CLLocationDegrees(Double(userLong)!))
myQuery = geoFire.query(at: location, withRadius: distance)
myQuery.observe(.keyEntered, with: { (key, location) in
print(key)
})
}