I have an VB .NET application in which I need to collect some range data prior to searching a database for a report. I have tried the examples given in this forum, to no avail. What I cannot seem to get straight is how to get the data and key-press data from the second form back to the first.

When the user presses a menu button I want to show a small form(form2) whereiin the user enters the search keys, then presses an "Ok" button. When the Ok button is pressed I want the key data available to the application(form1) and the form2 to disappear. The user will also be able to press a "cancel" button on form2 wherein the application(form1) will be able to so note.

I've looked here and elsewhere and tried dozens of approaches, all have failed on one way or another. In the code below I've stripped my attempts and left the basic code in hopes someone can help in what should be a simple problem. I will surely appreciate any help offered.

Here is what i've done...

Created Form2 with two text boxes and two buttons. I'd put the graphics here but I don't know how.

In form2

VB Code:
  1. Public Class Form2
  2.     Inherits System.Windows.Forms.Form
  3. #Region " Windows Form Designer generated code "
  4. #End Region
  5.     Public BookNumberLow As Integer
  6.     Public BookNumberHigh As Integer
  7.     Public GetKeyStatus As Boolean
  8.     Public Sub main()
  9.     End Sub
  10.     Private Sub Ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Ok.Click
  11.         BookNumberLow = Int(BookNumberLowBox.Text)
  12.         BookNumberHigh = Int(BookNumberHighBox.Text)
  13.         If BookNumberLow > BookNumberHigh Then
  14.             MessageBox.Show("Starting Book Number must not be greater than Ending Book Number", "Error", MessageBoxButtons.OK)
  15.         Else
  16.             GetKeyStatus = True
  17.         End If
  18.     End Sub
  19.  
  20.     Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
  21.         GetKeyStatus = False
  22.     End Sub
  23.     Public Property Status() As Boolean
  24.         Get
  25.             Return GetKeyStatus
  26.         End Get
  27.         Set(ByVal Value As Boolean)
  28.             GetKeyStatus = Value
  29.         End Set
  30.     End Property
  31.     Public Property Hi() As Integer
  32.         Get
  33.             Return BookNumberHighBox.Text
  34.         End Get
  35.         Set(ByVal Value As Integer)
  36.             BookNumberHighBox.Text = Value
  37.         End Set
  38.     End Property
  39.     Public Property Low() As Integer
  40.         Get
  41.             Return BookNumberLowBox.Text
  42.         End Get
  43.         Set(ByVal Value As Integer)
  44.             BookNumberLowBox.Text = Value
  45.         End Set
  46.     End Property
  47. End Class

in form1

VB Code:
  1. Private Sub MenuItem21_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem21.Click
  2.         Dim GetKeys As New Form2
  3.         GetKeys.ShowDialog(Me)
  4. '
  5. 'Code to get the key pressed in form2 and the low and high keys
  6. '
  7.         Call PrintByTitle()
  8.     End Sub