Example for OHIO in Visual Basic

Top  Previous  Next

Public Class Form1

   Dim AxOHIOManager1 As zOHIO.OHIOManager

 

   Private Sub RefreshSessionsCombo()

       Dim i As Integer

 

       ComboBox1.Items.Clear()

       For i = 0 To (AxOHIOManager1.Sessions.Count - 1)

           ComboBox1.Items.Add(AxOHIOManager1.Sessions.Item(i).sessionName)

       Next i

       ComboBox1.SelectedIndex = 0

   End Sub

 

   Private Function IfThen(ByVal BoolValue As Boolean, ByVal OnTrue As String, ByVal OnFalse As String) As String

       If BoolValue Then

           Return OnTrue

       Else

           Return OnFalse

       End If

   End Function

 

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

       Try

           AxOHIOManager1.Sessions.Refresh()

           RefreshSessionsCombo()

       Catch ex As Exception

           MsgBox(ex.ToString)

           Exit Sub

       End Try

       'TextBox3.Text = AxOHIOManager1.Sessions.Item(TextBox1.Text).Screen.Fields.Item(Val(TextBox2.Text)).String

   End Sub

 

   Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

       Try

           TextBox3.Text = AxOHIOManager1.Sessions.Item(ComboBox1.Text).Screen.Fields.Item(Val(MaskedTextBox1.Text)).String

       Catch ex As Exception

           MsgBox(ex.ToString)

       End Try

   End Sub

 

   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

       Try

           AxOHIOManager1.Sessions.Item(ComboBox1.Text).Screen.Fields.Item(Val(MaskedTextBox1.Text)).String = TextBox3.Text

       Catch ex As Exception

           MsgBox(ex.ToString)

       End Try

   End Sub

 

   Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

       Dim SessionType As String

       Dim FieldIdx As Integer

 

       ListBox1.Items.Clear()

       ListBox1.Items.Add("Session Name: " + AxOHIOManager1.Sessions.Item(ComboBox1.Text).sessionName)

       If (AxOHIOManager1.Sessions.Item(ComboBox1.Text).SessionType = zOHIO.OHIO_TYPE.OHIO_TYPE_3270) Then

           SessionType = "3270"

       ElseIf (AxOHIOManager1.Sessions.Item(ComboBox1.Text).SessionType = zOHIO.OHIO_TYPE.OHIO_TYPE_5250) Then

           SessionType = "5250"

       ElseIf (AxOHIOManager1.Sessions.Item(ComboBox1.Text).SessionType = zOHIO.OHIO_TYPE.OHIO_TYPE_VT) Then

           SessionType = "VT"

       Else

           SessionType = "UNKNOWN"

       End If

       ListBox1.Items.Add("Session Type: " + SessionType)

       ListBox1.Items.Add("Rows: " + Str(AxOHIOManager1.Sessions.Item(ComboBox1.Text).Screen.Rows))

       ListBox1.Items.Add("Cols: " + Str(AxOHIOManager1.Sessions.Item(ComboBox1.Text).Screen.Columns))

       ListBox1.Items.Add("Fields: " + Str(AxOHIOManager1.Sessions.Item(ComboBox1.Text).Screen.Fields.Count))

       With AxOHIOManager1.Sessions.Item(ComboBox1.Text)

           For FieldIdx = 0 To (.Screen.Fields.Count - 1)

               ListBox1.Items.Add("   Field Nº: " + Str(FieldIdx) + Chr(13))

               ListBox1.Items.Add("      Start Pos: " + Str(.Screen.Fields.Item(FieldIdx).Start) + Chr(13))

               ListBox1.Items.Add("      End Pos: " + Str(.Screen.Fields.Item(FieldIdx).End) + Chr(13))

               ListBox1.Items.Add("      Length: " + Str(.Screen.Fields.Item(FieldIdx).Length) + Chr(13))

               ListBox1.Items.Add("      Data: " + .Screen.Fields.Item(FieldIdx).String + Chr(13))

               ListBox1.Items.Add("      Attributes:" + Chr(13))

               ListBox1.Items.Add("         Modified: " + IfThen(.Screen.Fields.Item(FieldIdx).Modified, "Yes", "No") + Chr(13))

               ListBox1.Items.Add("         Protected: " + IfThen(.Screen.Fields.Item(FieldIdx).Protected, "Yes", "No") + Chr(13))

               ListBox1.Items.Add("         Numeric: " + IfThen(.Screen.Fields.Item(FieldIdx).Numeric, "Yes", "No") + Chr(13))

               ListBox1.Items.Add("         HighIntensity: " + IfThen(.Screen.Fields.Item(FieldIdx).HighIntensity, "Yes", "No") + Chr(13))

               ListBox1.Items.Add("         PenSelectable: " + IfThen(.Screen.Fields.Item(FieldIdx).PenSelectable, "Yes", "No") + Chr(13))

               ListBox1.Items.Add("         Hidden: " + IfThen(.Screen.Fields.Item(FieldIdx).Hidden, "Yes", "No") + Chr(13))

               ListBox1.Items.Add("----------------------------------------------------------------------" + Chr(13))

           Next FieldIdx

       End With

   End Sub

 

   Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

       Try

           AxOHIOManager1.Sessions.Item(ComboBox1.Text).Screen.SetString(TextBox3.Text, Val(MaskedTextBox2.Text))

       Catch ex As Exception

           MsgBox(ex.ToString)

       End Try

   End Sub

 

   Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

       Try

           AxOHIOManager1.Sessions.Item(ComboBox1.Text).Screen.SendKeys(TextBox3.Text, Val(MaskedTextBox2.Text))

       Catch ex As Exception

           MsgBox(ex.ToString)

       End Try

   End Sub

 

   Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

       If Not AxOHIOManager1.Sessions.Item(ComboBox1.Text).Screen.WaitForNewScreen(10000) Then

           MsgBox("TIMEOUT: Wait for New Screen")

       End If

   End Sub

 

   Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

       Dim AidKeyCode As Integer

 

       If (ComboBox2.Text = "ATTN") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_ATTN

       ElseIf (ComboBox2.Text = "BTAB") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_BACKTAB

       ElseIf (ComboBox2.Text = "CLEAR") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_CLEAR

       ElseIf (ComboBox2.Text = "ENTER") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_ENTER

       ElseIf (ComboBox2.Text = "FTAB") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_TABFORWARD

       ElseIf (ComboBox2.Text = "HELP") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_HELP

       ElseIf (ComboBox2.Text = "PA1") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PA1

       ElseIf (ComboBox2.Text = "PA2") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PA2

       ElseIf (ComboBox2.Text = "PA3") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PA3

       ElseIf (ComboBox2.Text = "PF1") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF1

       ElseIf (ComboBox2.Text = "PF10") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF10

       ElseIf (ComboBox2.Text = "PF11") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF11

       ElseIf (ComboBox2.Text = "PF12") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF12

       ElseIf (ComboBox2.Text = "PF13") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF13

       ElseIf (ComboBox2.Text = "PF14") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF14

       ElseIf (ComboBox2.Text = "PF15") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF15

       ElseIf (ComboBox2.Text = "PF16") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF16

       ElseIf (ComboBox2.Text = "PF17") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF17

       ElseIf (ComboBox2.Text = "PF18") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF18

       ElseIf (ComboBox2.Text = "PF19") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF19

       ElseIf (ComboBox2.Text = "PF2") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF2

       ElseIf (ComboBox2.Text = "PF20") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF20

       ElseIf (ComboBox2.Text = "PF21") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF21

       ElseIf (ComboBox2.Text = "PF22") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF22

       ElseIf (ComboBox2.Text = "PF23") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF23

       ElseIf (ComboBox2.Text = "PF24") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF24

       ElseIf (ComboBox2.Text = "PF3") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF3

       ElseIf (ComboBox2.Text = "PF4") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF4

       ElseIf (ComboBox2.Text = "PF5") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF5

       ElseIf (ComboBox2.Text = "PF6") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF6

       ElseIf (ComboBox2.Text = "PF7") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF7

       ElseIf (ComboBox2.Text = "PF8") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF8

       ElseIf (ComboBox2.Text = "PF9") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PF9

       ElseIf (ComboBox2.Text = "PGDOWN") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PGDOWN

       ElseIf (ComboBox2.Text = "PGUP") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PGUP

       ElseIf (ComboBox2.Text = "PRINT") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_PRINT

       ElseIf (ComboBox2.Text = "SYSREQ") Then

           AidKeyCode = zOHIO.OHIO_AID_KEY.OHIO_AID_KEY_SYSREQ

       Else

           Exit Sub

       End If

       Try

           AxOHIOManager1.Sessions.Item(ComboBox1.Text).Screen.SendAid(AidKeyCode)

       Catch ex As Exception

           MsgBox(ex.ToString)

       End Try

   End Sub

 

   Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

       Button9.Enabled = False

       Try

           AxOHIOManager1 = New zOHIO.OHIOManager

           AxOHIOManager1.Sessions.AddSession("", "A")

           'AxOHIOManager1.Sessions.AddSession("", "B")

           ListBox1.Enabled = True

           TextBox3.Enabled = True

           MaskedTextBox1.Enabled = True

           MaskedTextBox2.Enabled = True

           ComboBox1.Enabled = True

           ComboBox2.Enabled = True

           ComboBox2.SelectedIndex = 3

           ListBox1.Items.Clear()

           TextBox3.Clear()

           MaskedTextBox1.Text = "0"

           MaskedTextBox2.Text = "0"

           Button1.Enabled = True

           Button2.Enabled = True

           Button3.Enabled = True

           Button4.Enabled = True

           Button5.Enabled = True

           Button6.Enabled = True

           Button7.Enabled = True

           Button8.Enabled = True

           Button10.Enabled = True

       Catch ex As Exception

           Button1.Enabled = False

           Button2.Enabled = False

           Button3.Enabled = False

           Button4.Enabled = False

           Button5.Enabled = False

           Button6.Enabled = False

           Button7.Enabled = False

           Button8.Enabled = False

           Button9.Enabled = True

           Button10.Enabled = False

           ListBox1.Enabled = False

           TextBox3.Enabled = False

           MaskedTextBox1.Enabled = False

           MaskedTextBox2.Enabled = False

           ComboBox1.Enabled = False

           ComboBox2.Enabled = False

           MsgBox(ex.ToString)

           AxOHIOManager1 = Nothing

           Exit Sub

       End Try

       RefreshSessionsCombo()

   End Sub

 

   Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

       Button1.Enabled = False

       Button2.Enabled = False

       Button3.Enabled = False

       Button4.Enabled = False

       Button5.Enabled = False

       Button6.Enabled = False

       Button7.Enabled = False

       Button8.Enabled = False

       Button9.Enabled = True

       Button10.Enabled = False

       ListBox1.Enabled = False

       TextBox3.Enabled = False

       MaskedTextBox1.Enabled = False

       MaskedTextBox2.Enabled = False

       ComboBox1.Enabled = False

       ComboBox2.Enabled = False

       AxOHIOManager1 = Nothing

   End Sub

End Class