Search a String

Hi All, I have a form which contains number of fields i have action button that needs to search for a particular text given in the search string and display the result in a message box.How can this be done.

I tried using findstring method of notesuidocument but that is not working.

Pls help me with any codings or examples that performs the above operation.

Thanks in Advance

Subject: Search a String

If Findstr isn’t working for you then you either have to figure out why it’s not working or come up with a different approach. I would suggest as an alternative to use the Items property of Notesdocument to get the list of items in the document, and then you can use the LS Instr() function to see if a particular item contains the string you are searching for.

Subject: RE: Search a String

Hi MR.Jack I first of all thank you for the information you have posted.I tried a code with Instr() it works fine,but after searching a string i am appending some text to the search string to uniquely identify it.

When i try to search a same text again the resulted search string gets replaced with a old search string value.I need to append the new search values with old string values.i Hereby have attached a the code.

On Error Goto errorpara

Dim session As New NotesSession

Dim db As notesdatabase

Set db = session.CurrentDatabase

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Set uidoc = ws.CurrentDocument

Dim doc As NotesDocument	

Set doc = uidoc.Document

Dim newdoc As New  NotesDocument(db)

newdoc.form = "[frmdisplayinfo] "

If Not ws.DialogBox("[frmdisplayinfo]", True, True, False, False, False, False, "Page Publisher - Enter Details", newdoc,,False) Then

	newdoc.Remove True

	Exit Sub

End If

values = newdoc.rd_type(0)

ss = newdoc.searchstring(0)

Msgbox Cstr(ss)

fldlist = doc.GetItemValue("docfields")

Msgbox Join(fldlist)

For countVar = 1 To Ubound(doc.docfields)

	currentfield = fldlist(countVar)

	'Msgbox currentfield,,Cstr(countVar)

	pos = Instr ( doc.GetItemValue(currentfield)(0) ,Cstr(ss) )

	If Not pos = 0 Then

		uidoc.EditMode = True

		Msgbox "String Found in" & currentfield,,"String Value Found"

		If values="0" Then

			Call doc.ReplaceItemValue(currentfield,"<b>" & ss & "</b>")	

		Elseif  values="1" Then

			Call doc.ReplaceItemValue(currentfield,"<i>" & ss & "</i>")	

		Elseif values="2" Then

			tempurl = {<a href ="http://}+newdoc.url(0)+{">}+ ss +{</a>}

			Call doc.ReplaceItemValue(currentfield, tempurl)

		Elseif values="3" Then

			Dim x As Variant

			x=newdoc.GetItemValue("rd_color")(0)

			Msgbox x

			Dim tmp1 As String

			tmp1={<span style="background:}+newdoc.GetItemValue("rd_color")(0)+{">}+ ss +{</span>}

			'tmp1={<span style=}"background:black; color:#ff0000;">tmp1={<span style="background:#FFFF00">}+ ss +{</span>}

			'tmp1={<font color='}+ "Green" + {'>} + ss + {</font>}		

			Call doc.ReplaceItemValue(currentfield,tmp1)

		End If

		Call uidoc.Refresh

		Call uidoc.Save

	End If

Next

Exit Sub

errorpara:

Msgbox Err() & ": " & Error()&" at line "&Erl,, "Error Occurred"	

Exit Sub