SunQuest
 
       Code Examples
  Home arrow Code Examples arrow Page 3 - Searching Body Text with textRange: Buildi...
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Actuate Whitepapers 
VeriSign Whitepapers 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
CODE EXAMPLES

Searching Body Text with textRange: Building on the Script and the VBScript Alternative
By: Dan Wellman
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 16
    2005-06-30

    Table of Contents:
  • Searching Body Text with textRange: Building on the Script and the VBScript Alternative
  • Add a Flag
  • The VBScript
  • VBScript Continued

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    At the virtual BlackBerry Technical Seminar 2008, you can ask your development questions directly of Research In Motion® (RIM) experts, and take advantage of learning opportunities designed uniquely for BlackBerry solution developers. Register Today!

    Searching Body Text with textRange: Building on the Script and the VBScript Alternative - The VBScript


    (Page 3 of 4 )

    As promised, I will now give you the VBScript variation of the whole script.  Some may question what the point of using VBScript actually is when the JavaScript version does everything that is needed from it?  I’m including this s o that people can choose whichever version they use depending on whichever language they prefer.   Additionally, as VBScript is basically a cut-down version of Visual Basic, learning VBScript is an excellent primer for those wishing to progress to application programming with full VB or even VB.NET.  Those that don’t want to know should look away now.

    The VBScript file in its entirety then is as follows.  I won’t go through the code step by step because you should already be able to tell what is going on in the file:

    dim searchWord
    dim range
    dim match
    dim button1clicked

    sub buttonSearch_onclick()
      button1clicked = 1
      set range = document.body.createTextRange()
      searchWord=window.showModalDialog("Searchwindow.htm",
       null,"dialogWidth:300px;dialogHeight:200px;status:no;help:no;")
      if searchWord="" then
        exit sub
      end if

    match = range.findText(searchWord,0,2)
    if match <> false then
      range.select()
    else
      MsgBox "Couldn't find " & searchWord,vbExclamation,"No Match"
    end if
    end sub

    sub buttonNext_onclick()
      if searchWord="" then
        MsgBox "No search value entered",vbCritical, "No Search Word"
        exit sub
      end if
      if button1clicked <> 1 then
        MsgBox "Please enter a search value first", vbCritical, "No Search Word"
        exit sub
      end if
      range.move "word", 1
      range.moveEnd "word", 1000
      match = range.findText(searchWord,0,2)
    if match <> false then
      range.select()
    else
      MsgBox "Couldn't find any more instances of " & searchWord,vbExclamation,"No Further Matches"
    end if
    end sub

    Initially, the global variables are defined using the dim keyword instead of the var keyword.  This is standard practice in VBScript.  Next up, although VBScript does support the use of functions, this script has made use of subs instead.

    More Code Examples Articles
    More By Dan Wellman


     

    CODE EXAMPLES ARTICLES

    - Handling Animations and Bitmaps Using GDI+ f...
    - Download a Web Page using the WebClient
    - Creating a Chart using Data from a Database ...
    - The Basics of Charting with the MS Chart Con...
    - Searching Body Text with textRange: Enter th...
    - Searching Body Text with textRange: Building...
    - Searching Body Text with textRange, part 1: ...
    - First Steps in Programming
    - Programming in C
    - Quick Introduction to ASF,ASX, and Networkin...
    - SatView: Pointer Perfect, Part 2: Constructi...
    - SatView: Pointer Perfect, Part 1
    - Style Case Studies: Construction Unions
    - Creating an Engine for Games for Windows
    - Style Case Studies: Generic Callbacks

    Click Here




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway