home *** CD-ROM | disk | FTP | other *** search
- Public Class Form1
- Inherits System.Windows.Forms.Form
-
- #Region " Windows Form Designer generated code "
-
- Public Sub New()
- MyBase.New()
-
- 'This call is required by the Windows Form Designer.
- InitializeComponent()
-
- 'Add any initialization after the InitializeComponent() call
-
- End Sub
-
- 'Form overrides dispose to clean up the component list.
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
-
- 'Required by the Windows Form Designer
- Private components As System.ComponentModel.IContainer
-
- 'NOTE: The following procedure is required by the Windows Form Designer
- 'It can be modified using the Windows Form Designer.
- 'Do not modify it using the code editor.
- Friend WithEvents Button1 As System.Windows.Forms.Button
- Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
- Friend WithEvents Label1 As System.Windows.Forms.Label
- Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox
- Friend WithEvents Button2 As System.Windows.Forms.Button
- <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
- Me.Button1 = New System.Windows.Forms.Button()
- Me.TextBox1 = New System.Windows.Forms.TextBox()
- Me.Label1 = New System.Windows.Forms.Label()
- Me.CheckBox1 = New System.Windows.Forms.CheckBox()
- Me.Button2 = New System.Windows.Forms.Button()
- Me.SuspendLayout()
- '
- 'Button1
- '
- Me.Button1.Location = New System.Drawing.Point(8, 16)
- Me.Button1.Name = "Button1"
- Me.Button1.Size = New System.Drawing.Size(120, 64)
- Me.Button1.TabIndex = 0
- Me.Button1.Text = "Run wsh-extract.iim macro and return results to VB.NET"
- '
- 'TextBox1
- '
- Me.TextBox1.BackColor = System.Drawing.SystemColors.Info
- Me.TextBox1.Location = New System.Drawing.Point(144, 48)
- Me.TextBox1.Multiline = True
- Me.TextBox1.Name = "TextBox1"
- Me.TextBox1.Size = New System.Drawing.Size(112, 32)
- Me.TextBox1.TabIndex = 1
- Me.TextBox1.Text = "TextBox1"
- '
- 'Label1
- '
- Me.Label1.Location = New System.Drawing.Point(144, 24)
- Me.Label1.Name = "Label1"
- Me.Label1.Size = New System.Drawing.Size(100, 16)
- Me.Label1.TabIndex = 2
- Me.Label1.Text = "Status:"
- '
- 'CheckBox1
- '
- Me.CheckBox1.Location = New System.Drawing.Point(16, 96)
- Me.CheckBox1.Name = "CheckBox1"
- Me.CheckBox1.Size = New System.Drawing.Size(240, 16)
- Me.CheckBox1.TabIndex = 3
- Me.CheckBox1.Text = "Run in System Tray"
- '
- 'Button2
- '
- Me.Button2.Location = New System.Drawing.Point(224, 120)
- Me.Button2.Name = "Button2"
- Me.Button2.Size = New System.Drawing.Size(48, 24)
- Me.Button2.TabIndex = 4
- Me.Button2.Text = "Exit"
- '
- 'Form1
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
- Me.ClientSize = New System.Drawing.Size(292, 157)
- Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button2, Me.CheckBox1, Me.Label1, Me.TextBox1, Me.Button1})
- Me.Name = "Form1"
- Me.Text = "VB.NET Scripting Interface Demo"
- Me.ResumeLayout(False)
-
- End Sub
-
- #End Region
- Dim iim1 As Object
- Dim iret As Integer
- Dim iplay As Integer
- Dim s As String
- Dim sExtractedText As String
- Dim sPart0 As String
- Dim sPart1 As String
- Dim sSplit() As String 'Array to hold the results of the SPLIT command
-
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
-
- 'Create an object based on the Scripting Interface
- 'This way we can copy & paste all the VBS (Windows Scripting) example code
- 'directly into a VB.NET project
- TextBox1.Text = "Initializing..."
- iim1 = CreateObject("iimwsh.iim")
-
- If CheckBox1.Checked = True Then
- iret = iim1.iimInit("-tray", True)
- Else
- iret = iim1.iimInit("", True)
- End If
-
- 'Tip: With iret = iim1.iimInit(sCmdLine, FALSE) you can ask the Scripting Interface to
- 'connect to an already open IIM browser. If there is no IIM browser open, the return value
- 'will be negative.
-
- TextBox1.Text = "Set Display..."
- iret = iim1.iimDisplay("Extract Example")
-
- 'Normally the Scripting Interface waits about 10 seconds before a Scripting Interface
- 'timeout error occurs (for example, if a user closed the IIM browser while it was running,
- 'please do not confuse this with the BROWSER timeout errors if a web page loads too slow.)
- 'iret = iim1.iimSetInternal("INTERFACETIMEOUT", 1) 'reduce the interface timeout to 1s
-
- TextBox1.Text = "Running Macro..."
- If CheckBox1.Checked = True Then iret = iim1.iimSet("-tray", "") 'apply settings before every PLAY command
- iplay = iim1.iimPlay("wsh-extract")
- sExtractedText = iim1.iimGetLastMessage()
- iret = iim1.iimExit
-
- If iplay = 2 Then
- TextBox1.Text = "Done!"
- sSplit = Split(sExtractedText, "[EXTRACT]")
- sPart0 = sSplit(0)
- If UBound(sSplit) > 0 Then sPart1 = sSplit(1)
- s = "One US$ costs " + sPart0 + " EURO or " + sPart1 + " British Pounds (GBP)"
- MsgBox(s)
- TextBox1.Text = "Done!"
- End If
-
- If iplay = 1 Then
- TextBox1.Text = "Done, but no data extracted"
- End If
-
- If iplay < 0 Then
- 'In this case, sExtractedText contains
- ' the *error* information returned by iimGetLastMessage()
- TextBox1.Text = sExtractedText
- End If
-
- End Sub
-
-
- Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
- End
- End Sub
- End Class
-