Sunday, August 12, 2007

Fun stuff with the FieldListener class

BIIG flash.. Sorry, but don't know how to get it smaller.







In the demo above, I have a form with a "Microsoft Web Browser" object. If the "search" field contains the words wiki, amazon or amazonuk, I use the searchengine at the site to search for the rest of the parameters.

The search-sub:

Sub search
Dim ws As New NotesUIWorkspace
Dim arrAction As Variant
Dim sstr As String, baseURL As String

arrAction = Split(ws.CurrentDocument.FieldGetText( "search" ), " ")


Dim browser As Variant
Set browser = ws.CurrentDocument.GetObject("Microsoft Web Browser")
If browser.width <> 950 Then
browser.width = 950
browser.height = 700
End If

sstr = Replace( Implode(arrAction, "+"), arrAction(0)+"+", "")
Select Case Lcase( arrAction(0) )
Case "wiki"
baseURL = "http://en.wikipedia.org/wiki/Special:Search?search="

Case "amazonuk"
baseURL = "http://www.amazon.co.uk/s/026-5318277-1707602?&field-keywords="

Case "amazon"
baseURL = "http://www.amazon.com/s/026-5318277-1707602?&field-keywords="

Case Else
baseURL = arrAction(0)
sstr = ""
End Select

Call browser.navigate( baseurl + sstr )
End Sub

0 comments: