.NET Visual BASIC client

The Visual BASIC version of the client uses the same mvs Web Service and user interface as used in the C-Sharp example. See the .NET C-Sharp Client example to create the project, add the Web Service reference and create the UI.

Visual BASIC client examples are located in the <MVS.install.dir>\samples\mv-ws-vb\ folder of your installation.

The Visual BASIC event handlers that call the mvs Web Service are illustrated below:

search-inventory

Private Sub btnSearch_Click(ByVal sender As System.Object, 
ByVal e As System.EventArgs) Handles btnSearch.Click

   Try
      Dim mvsService As New mvs.mvsService()
      mvsService.Url = txtURL.Text

      Dim searchInventory = New mvs.searchinventory()
      searchInventory.DESC = "[" + txtDescription.Text + "]"

      Dim response As mvs.searchinventoryResponse
      response = mvsService.searchinventory(searchInventory)
      Dim rows() As mvs.searchinventoryRow
      rows = response.searchinventoryRowSet

      Dim gridRow(6) As String
      dataGridSearchInventoryResults.Rows.Clear()
      For Each row As mvs.searchinventoryRow In rows
         Dim i As Integer
         For i = 0 To row.ID.Length - 1
            gridRow(0) = row.ID(i)(0)
            gridRow(1) = row.DESCRIPTION(i)(0)
            gridRow(2) = row.RETAILPRICE(i)(0)
            gridRow(3) = row.PROMOPRICE(i)(0)
            gridRow(4) = row.QTYONHAND(i)(0)
            gridRow(5) = row.TYPE(i)(0)
            dataGridSearchInventoryResults.Rows.Add(gridRow)
         Next
      Next
   Catch Exception As Exception
      MessageBox.Show(Exception.Message, "Error accessing web services", 
      MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
   End Try

End Sub

check-inventory

Private Sub btnExecute_Click(ByVal sender As System.Object, 
ByVal e As System.EventArgs) Handles btnExecute.Click

   Try

      Dim mvsService As New mvs.mvsService()
      mvsService.Url = txtURL.Text

      Dim checkInventory As New mvs.checkinventory()
      checkInventory.ITEMID = txtItemID.Text
      Dim response As mvs.checkinventoryResponse
         response = mvsService.checkinventory(checkInventory)
      txtResponse.Text = response.ITEM

   Catch Exception As Exception
      MessageBox.Show(Exception.Message, "Error accessing web services", 
      MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)

   End Try

End Sub

check-inventory-by-location

Private Sub btnCheckInventory_Click(ByVal sender As System.Object, 
ByVal e As System.EventArgs) Handles btnCheckInventory.Click

   Try
      Dim mvsService As New mvs.mvsService()
      Dim checkInventorybylocation As New mvs.checkinventorybylocation()
      Dim idList() As String = txtItemIDs.Text.Replace("\r\n", ",").Split(",")
      Dim locationList() As String = 
         txtLocations.Text.Replace("\r\n", ",").Split(",")

      ' Set the locations array
      ' -----------------------
      Dim locations(locationList.Length) As mvs.locations

      For i As Integer = 0 To locationList.Length - 1
         locations(i) = New mvs.locations()
         locations(i).locationname = locationList(i)
      Next

      ' Set the items array
      ' -------------------
      Dim items(idList.Length) As mvs.items
      For i As Integer = 0 To idList.Length - 1
         items(i) = New mvs.items()
         items(i).itemid = idList(i)
         items(i).locations = locations
      Next

      ' Create the inventory request and set it's values
      ' ------------------------------------------------
      Dim request As New mvs.inventoryrequest
      request.customerid = "123"
      request.items = items

      checkInventorybylocation.REQUEST = request

      Dim response As mvs.checkinventorybylocationResponse
      response =   mvsService.checkinventorybylocation(checkInventorybylocation)
      Dim result() As mvs.items1
      result = response.inventoryresponse.items

      Dim gridRows(10) As String
      dataGridSearchInventoryByLocationResults.Rows.Clear()

      For i As Integer = 0 To result.Length - 1
         Dim inventory() As mvs.inventory
         inventory = result(i).inventory
         For j As Integer = 0 To inventory.Length - 1
            If j = 0 Then
               gridRows(0) = result(i).itemid
               gridRows(1) = result(i).description
               gridRows(2) = result(i).listprice.ToString()
               gridRows(3) = result(i).saleprice.ToString()
            Else
               gridRows(0) = ""
               gridRows(1) = ""
               gridRows(2) = ""
               gridRows(3) = ""
            End If
            gridRows(4) = inventory(j).locationid
            gridRows(5) = inventory(j).locationname
            gridRows(6) = inventory(j).qtyonhand.ToString()
            dataGridSearchInventoryByLocationResults.Rows.Add(gridRows)
         Next
      Next
   Catch Exception As Exception
      MessageBox.Show(Exception.Message, "Error accessing web services", 
      MessageBoxButtons.RetryCancel, MessageBoxIcon.Error)
   End Try
End Sub

list-customers

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

   Try

      Dim mvsService As New mvs.mvsService()
      mvsService.Url = txtURL.Text


      Dim listcustomers As New mvs.listcustomers()
      listcustomers. STATE = txtState. Text


      Dim response As mvs.mvslistcustomersResponse
      response = mvsService.listcustomers(listcustomers)


      Dim rows() As mvs.mvslistcustomersRow
      rows = response.mvslistcustomersRowSet


      Dim gridRow(5) As String
      dataGridCustomers.Rows.Clear()

      For Each row As mvs.mvslistcustomersRow In rows
         For i As Integer = 0 To row.CUSTOMERID.Length - 1
            gridRow(0) = row.CUSTOMERID(i)(0)
            gridRow(1) = row.ORGANIZATIONNAME(i)(0)
            Dim address As String = row.ADDRESS(i)(0) + "," + row.CITY(i) + "," + 
               (0)row.STATE(i)(0) + "," + row.POSTALCODE(i)(0)
            gridRow(2) = address
            gridRow(3) = row.PHONENUMBER(i)(0)
            gridRow(4) = row.CONTACTNAME(i)(0)
            dataGridCustomers.Rows.Add(gridRow)
         Next i
      Next row
 
   Catch Exception As Exception
      MessageBox.Show(Exception.Message, "Error accessing web services", 
         MessageBoxButtons.RetryCancel, MessageBoxlcon.Error)
   End Try

End Sub

quote

Private Sub btnExecuteQuote_Click(ByVal sender As System.Object, 
ByVal e As System.EventArgs) Handles btnExecuteQuote.Click

   Try

      Dim mvsService As New mvs.mvsService()
      mvsService.Url = txtURL.Text


      Dim quote As New mvs.quote()
      quote.SYMBOLS = txtSymbol.Text


      Dim response As mvs.mvsquoteResponse = mvsService.quote(quote)
      dataGridQuote.Rows.Clear()

      Dim gridRow(6) As String

      Dim AM As Char = Chr(254)

      Dim name() As String = response.COMPANYNAMES.Split(AM)
      Dim price() As String = response.PRICES.Split(AM)
      Dim change() As String = response.CHANGEAMTS.Split(AM)
      Dim lastTrade() As String = response.LASTTRADES.Split(AM)
      Dim volume() As String = response.VOLUMES.Split(AM)
      Dim avgVolume() As String = response.AVGVOLUMES.Split(AM)

      For I As Integer = 0 To name.Length - 1
         gridRow(0) = name(I)
         gridRow(1) = price(I)
         gridRow(2) = change(I)
         gridRow(3) = lastTrade(I)
         gridRow(4) = volume(I)
         gridRow(5) = avgVolume(I)
         dataGridQuote.Rows.Add(gridRow)
      Next


   Catch Exception As Exception
      MessageBox.Show(Exception.Message, "Error accessing web services", 
         MessageBoxButtons.RetryCancel, MessageBoxlcon. Error)
   End Try
 
End Sub
End Class