Visual Basic.NET





Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to  Visual Basic pre-2002, it is not the same technology,

Share tech news, updates, or what's on your mind.

Sign up to Post


I'm just wondering why I can't get specific error messages anymore in Visual Studio when an exception occurs.

For example, I know where this error occured because I'm working in that section of the application, but it used to highlight the line and tell me exactly what caused the problem, now I get a generic error like this:

An unhandled exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll
Additional information: Conversion from string "" to type 'Double' is not valid.

It no longer specifies the line number or highlight the error,

I attached a print screen

Thank you for the help!
Get expert help—faster!
LVL 11
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

I have a template in Lotus Notes. Is it possible to somehow send an email using this template. So far I only know how to send normal email, but not an email with template.
I am needing to compare values in two lists which are different types. What I need to do is find out if the AttendeeID is in both lists. If it is in both lists then do nothing, however, if the AttendeeID is not in both lists then we need to add that information to another list. I was trying to use LINQ to do this, however, I'm not doing something correctly and I'm not sure as to where I'm wrong. Below is the code that I currently have.

If TypeOf e.Item Is GridDataInsertItem Then
            'Remove individuals from list if they exist already in the outcome memos table before binding the list.
            Dim newClients As RadDropDownList = CType(e.Item.FindControl("rdlClientNames"), RadDropDownList)
            Dim getAllClients As New IndividualsBase
            Dim indList As List(Of IndividualsBase) = getAllClients.SelectIndividuals(0,True,Nothing,0)

            Dim getIndividuals As New OutcomesMemos
            Dim indMemo As List(Of OutcomesMemos) = getIndividuals.SelectOutcomeMemos("Active")
            Dim totalInds As List(Of IndividualsBase)

            indMemo = indMemo.Where(Function(xMemos) Not indList.Contains(xMemos.AttendeeID)).ToList()

            If totalInds.Count = 0 Then
                Dim list As New RadDropDownList
                list.Items.Item(0).Text = "All Individuals Have Been Added"
                newClients.DataSource = totalInds
                newClients.DataTextField = "FullNameID"

Open in new window

i create an data application by dragging dataset table into   my form . and i found that i cant delete rows in my dataset ,in fact, i cant find deletecommand in tableadapter property how can i fix it.
after updating i receive this error "Update requires a valid DeleteCommand when passed DataRow collection with deleted rows."

I want to use a barcode reader with my or VBA software.
Where do I start?

Dear Experts,

I need to add Hyperlink/URL for page redirection in DataGrid control..In web page first I am searching the the resultsSet (6 columns) then binding it in DataGrid. Below is my sample code:


      <asp:DataGrid ID="dgResult" runat="server" CellPadding="2" AutoGenerateColumns="False"  Width="75px">
                <asp:EditCommandColumn ButtonType="PushButton" UpdateText="Save" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
                <asp:BoundColumn DataField="ACCT_ID"   HeaderText="ACCT ID      ReadOnly="False"></asp:BoundColumn>      
            <asp:BoundColumn DataField="Tran_ID"    HeaderText="TRANS ID"  ReadOnly="False"></asp:BoundColumn>      

aspx.VB code:

        Me.dgResult.DataSource = mAcct_DS.corp_actionlist
        Me.dgResult.Visible = True

Please suggest me the solution. I need to navigate from one page to another and in URL string one value will be passed from the hyperlink column (Consider ACCT_ID from above code).

We have a dataviewgrid  in VB.Net that displays different data on each row and different colors in some of the columns. How do we send the colors to the printer.  When using an MSFlexGrid in VB6 code, it works fine.  Appreciate any help!

I need a way of looping through an XML document and obtaining values using for the following: PHYSICALADDRESS:Street; PHYSICALADDRESS:city; PHYSICALADDRESS:state;TAXID:SSN;DOB:dob. I would like these values in seperate string variable so I can use later. See the attached XML document.
Can you give me example or idea on how to make this happen? Thank you.
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Hi All,

I am looking for either code or a control, which operates in a manner similar to the combo next to the label "Look In" in the image below:

Look in
I am aware of an currently use the BrowseForFolder type control, but its not exactly ideal - my preference is for a combobox that throws out a treeview controlwith the directories listed in the same manner ...


Sorry for my very limited English, i'm french.

Having a concern with a security dll provided by an external company, it responds too slowly in, 30 to 50 seconds which is unacceptable.

I am trying to create an application that would be hidden at boot time with a notifyicon and a dynamically create menu. This software would be the security management of our other software.

I then need my other software to interoperate the security dll management software, to allow the application to start and retrieve the access levels. (user / super user / admin)

I manage to manage the security part dll. My software recover all the information.

But for now I am trying to overcome two problems:
1) The dynamic creation of the notifyicon and the contextmenustrip. I can create the notifyicon, but the menu does not appear.
2) The dialogue between the 2 software. I found a tutorial to use remoting. It works perfectly, but from a console application, hence the dynamic creation of the notifyicon and contextmenustrip.

I will need a form in my management application. So I tested by creating a form with the notifyicon and the contextmenustrip.
I instantiate the form, without displaying it, and I add a menustrip to my contextMenu, but again I have the icon, but not the menu.

Code below:
 Public Shared Sub Main(ByVal args() As String)
            ' Création d'un nouveau canal d'écoute sur le port 1069
            Dim channel As TcpChannel = New 

Open in new window

I have a div tag that is heing opened in modal with a button click
<a onclick="ShowFilterPopUp()" role="button" id="add_staff">Filters</a>

Open in new window

I am running some code on a second button click (In the modal window)

It reloads a grid
That reload closes the window

When I add an export to File as part of the process
The file does export but the modal does not close.

I tried calling a second code from server side but the modal window still does not close.

        If chkACH.Checked = True Then
            ExportACH() - exports but modal window does not close
            ScriptManager.RegisterStartupScript(Me, [GetType](), "blah", "ShowFilterPopUpHide();", True)
        End If

Open in new window

        function ShowFilterPopUp() {

        function ShowFilterPopUpHide() {

Open in new window

I have a dataset being returned from SQL Server into my web form

It has a column  called BatchNumber that can be from 1 to 1000 rows

I also have a comma seperated string
strMyList = "1,3,5,7"

I would like to remove from strMyList any value not in the "longer list"

So that if the dataset does not have BatchNumber 3 then
strMyList would = "1,5,7"
I need assistance: I am developing a dispensing program that captures patients details(name, medical aid number, medical aid scheme), Doctors details(name, practice number), dispense(code) and list of medicines dispensed. I'm quiet ok with the design but I do not know how to save these data into one table and how. Perhaps someone who has the know-how could help me. Im using VB.Net with Visual Studio 2017 enterprise.
I am building a solution that will display KPI information on a set of large TV screens for our warehouse and we use Netsuite for our ERP. My netsuite developer that we have in house can build a REST API in netsuite that uses Token based authentication to expose the data that i need but i am having trouble finding information on how to connect to this API.
All help is much appreciated.
Regards Joel
I use to launch and use Microsoft Excel.  There is 1 computer, however, that will not launch excel when I run this code:

Imports XL = Microsoft.Office.Interop.Excel

Public Class Form1

    Dim xlApp As New XL.Application
    Dim wb As XL.Workbook
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        wb = xlApp.Workbooks.Add()
    End Sub
End Class

I have references to Microsoft.Office.Core and Microsoft.Office.Interop.Excel.  I am using Visual Studio 2015 and the Excel on the user's machine is 2010 Professional Plus.

Please see the attached error.

Thank you,

Elliot Semmelman
I have crystal report in that i have align Sum of details field to vertical in footer section. but it shows ### value filed width is bigger. Horizontally it shows correct.
This is the code :

Module Module1

    Dim name As String
    Dim cardn As Integer = 1

    Dim cardNum(3) As String
    Dim cardSuit(3) As String

    Sub Main()
        Dim des As String
        Dim des2 As String

        Console.WriteLine(vbCrLf & "Hello there..." & vbCrLf)

        Console.WriteLine("What is your name ?")
        name = Console.ReadLine()

        Console.WriteLine(vbCrLf & "Hello " & name & ", would you like Today play the card game : Yes/No")
        des = Console.ReadLine()

        If des = "yes" Then
                cardSuit(0) = Console.ReadLine()
                cardNum(0) = Console.ReadLine()

                cardSuit(1) = Console.ReadLine()
                cardNum(1) = Console.ReadLine()

                cardSuit(2) = Console.ReadLine()
                cardNum(2) = Console.ReadLine()

                Console.WriteLine("Three cards have been generated")

                Console.WriteLine("Okay " & name & ", would you like to compare the cards ? ")
                des2 = Console.ReadLine()

                While des2 = "yes"

                    If des2 <> "yes" Then
                        Console.WriteLine("Okay bye " & name)
                        Console.WriteLine("End Program ")
Free Tool: Site Down Detector
LVL 11
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

I am learning basic steps and working now on optimistic concurrency with MS access database and datagridview.
I want to see changes- updates of record in my database and I want to arrange situation that will give me concurrent violation. I want to be sure for testing this issue do I need to set up my MS Access database as: Do not copy? If somebody can elaborate this a little a bit.
Hi All - I have exported an email from MSOutlook to an MHT file. I have found that an Outlook file saved as a MHT file includes a div and a style - the div/style - I can see this as a triangle on the right side of the word From.. when I click on the triangle - the entire section - with the msg, contracts - when I click it again - it expands - see pic below:

Now what I would like to do is programatically from VB.NET, is toggle the style to contracted - and also how to delete them ...


Hi All,

I am starting Word through a Process ...

    Private WithEvents myProcess As New Process
    Private elapsedTime As Integer
    Private eventHandled As Boolean

    Public Event Exited As EventHandler

    ' Print a file with any known extension.
    Public Function PrintDoc(ByVal fileName As String) As Boolean

        elapsedTime = 0
        eventHandled = False

            ' Start a process to print a file and raise an event when done.
            With myProcess
                With .StartInfo
                    .FileName = fileName
                    ' myProcess.StartInfo.Verb = "Print"
                    .WindowStyle = ProcessWindowStyle.Maximized '.CreateNoWindow = True
                End With
                .EnableRaisingEvents = True
            End With


Open in new window

Once the process has started, how to can I access the Toolbars and Ribbons of that process and retrict the user to either closing the window, or saving the document - but nothing more (ie cannot saveas etc)


I am new to vb.Net and still learning.
 I am using Visula Studio Microsoft Visual Community 2015 and
 .NET Framework 4.5.2

 I am working on optimistic concurrency with datagridview. I want to update a field in MS access table.

 It is simple application just to get input how optimistic concurrency works.
 I have Ms Access database with one table, tblStudent. Table has five fields.

 - Student_Number autonumber and key filed,
 - StudnetName- text,
- Student_Surname –text,
 - Student_Group- number,
 - Student_Group_New -number default 0.

 I am updating only  field : Student_Group_New.

 In datagridview I added column “DataGridViewButtonColumn”  for each row for update event.
 I open form , Data grid view is populated with records from my table tblStudent properly. On form I can enter new value in column: Student_Group_New, then  I click update button I got message that Update is Successful but record in table is not updated.

 As record not updated it is not triggering Optimistic concurrency exception.
 I assume that I am missing something.
 Here is my code.

Imports System.Windows.Forms
Imports System.Data.OleDb
Imports System.Data

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Test_ADataSet.tblStudent' table. You can move, or remove it, as …
I have a fairly basic form that has a DataGridView with a tableadapter binding.

Updates and deletes work fine, but when it comes to the insert there is a need to pull the primary key value into the DGV

When I add a row it populates the ID column with a random GUID value
    Private Sub DGV1_DefaultValuesNeeded(sender As Object, e As DataGridViewRowEventArgs) Handles DGV1.DefaultValuesNeeded

        e.Row.Cells("ID").Value = Guid.NewGuid

   End Sub

Open in new window

What I need to be populated is Matters and Professionals PK value from the parent tables.  
I have inner join for the insert store procedure and it does populate the DVG, but does not update the database table.  
I'm using VS2010 with SQL Server back end and would now like to start using Data Source to connect rather then coding credentials in appconfig. I'm also worried about exposing SQL passwords. Is there a safe way to do this and can you refer me to an example please.

Visual Basic.NET





Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to  Visual Basic pre-2002, it is not the same technology,