Visual Basic.NET




Articles & Videos



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

Hello Experts.

I've made some good progress with learning how to interact with an Access database through VB.NET. The attached project includes some useful techniques for populating ComboBoxes with multiple columns using LINQ queries, and leverages Access' ability to generate Queries (which VS calls 'Views') for the purpose of connecting two related tables for populating the ComboBox list items, and any data bound form objects and DataGridViews.

This project uses two tables; one for a list of Players (which I call 'Roster') and one for a list of Teams. The Roster table has a Teams Key that joins to the Teams table which includes the Team Name attribute. I also decided that I wanted to include a picture of every player so Team Captains would have an easier time identifying who's who ("which of you guys is John Doe?"). So it was easy enough to add a new column to the Roster table in Access of type OLE/Object. I then added the code so the image file could be retrieved and attached to the bound PictureBox. That all works good, but since the PictureBox is only a tiny 120x90, I want to be sure the image file is sized correctly so it doesn't bloat the Access table too much.

To that end, I found a nice solution but it was in C#, so I'm not sure if I was able to convert it properly to Visual Basic. But the real head scratcher for me is understanding the concept of an IO.Stream which is how this image resizing solution is rigged. That leads to my real question -- how do I
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 Experts,

This is my program. I am using some private variable to hold the values. Then I am using them through out the program. I want to know is it the right way to do or I should keep them in the session variable and use them. I am curious to know that when many people access the same web page are these variables going to create problem or change the values.  I am using and

Thanks in advance.

Partial Class EditCustomerOrder
    Inherits System.Web.UI.Page
    Private Shared Calling_Form As String
    Private Shared CustomerID As Integer
    Private Shared LocationID As Integer
    Private Shared MenuOrderDate As DateTime
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        If Not IsPostBack Then
            Calling_Form = Request.QueryString("Calling_Form")
            If Session("EditCustOrder_Calling_Form") Is Nothing = False Then
                Calling_Form = Session("EditCustOrder_Calling_Form")
                Calling_Form = Request.QueryString("Calling_Form")
            End If

            If Session("EditCustOrder_MenuOrderDate") Is Nothing = False Then
                MenuOrderDate = Session("EditCustOrder_MenuOrderDate")
                MenuOrderDate = Request.QueryString("MenuDate")
            End If
EgEgI have checkbox that when' Checked' sets the  value of the checkbox into a textarea.

    Protected Sub chkReviewdate_CheckedChanged(sender As Object, e As EventArgs) Handles chkReviewdate.CheckedChanged
        txtNotes.Text = "Review date to be added or incorrect"
    End Sub

Open in new window

The problem is that when more than 1 checkbox is checked it overwrites the value in   txtNotes.Text with the latest checkbox value

What I would like to do is list ALL the values of the 'Checked' checkboxes, not just the last one. Whats the best way to achieve this?
I am using lotus notes to send email in .net application using c#. I am able to send mails from this application while i run this in my local host. But the thing is when host the application in local IIS server i am not able to send mails.
 I am getting the following error.
Notes error: Notes shared login failed with this ID file.
Please tell me why i am getting this error after hosting the application.

I am looking at a few different things. I am using ASP.NET 4.0 and VB.NET code-behind.

The main situation is this.

I have a page with an iFrame.  We'll call that Page 1 and the page in the iFrame as Page 2. The page of the iFrame on Page 2 is a URL location is external and that page cannot change.

Page 1 is polling the database running on reload of the page which invokes the Page_Load on the reload. That Page_Load is executing the stored procedure to check certain values in a table. Page 2 (the one in the iFrame) is where certain information is entered and will have a submit button. After a period of time, information from the Page 2 will go into the same table that I am polling on Page 1.

What is going on is every time Page1 reloads (based on like 10 second interval) the data in Page 2 (in the IFrame) is lost.

How can I keep that from happening?

I can think of one way, off the cuff, and that is to use the Page 1 and Page 2 as a frameset. And one Frame (for the Page 1) is doing the polling and reloading... The other frame is doing the Page 2 but in an iFrame.

When the user hits the "Submit" button on the second frameset (Page 2) then break out of the frameset and only have the Page 1.

Break out of the Frameset from the code behind of Page2 with JavaScript like? Or is there another way?

Page.RegisterClientScriptBlock("ResetPage", "<SCRIPT>top.location.href=" + Page1URL + "</SCRIPT>");

Open in new window

That is one option. Is there another …
OK, so I developed a program that has a green progress bar that turns purple when filling...however when you RDS into a Server 2012 Server it is Gray and fills with Green?


MarkRDS 2012 ServerWindows 7 Progress Bar
Hi Experts,

How to create a public variable which can be used only in the form. Suppose I have form1.aspx. How can I define a public variable which can be used only in form1 .no other form should able to access it.

Is it possible to call a function (in eg Module1) in an Excel cell?
Hi Experts,

I am testing my project in multiple computers and found a serious problem.

In Machine 1
I log in as an Admin. Then In the page I have to select Customer, location and Room. Then I click OK to go to a different page. (Sesson Admin='Y')

Then in Machine 2, I log in as a user.  select Customer, location and Room. Then I click OK to go to a different page (Sesson Admin='N')

When I come back machine 1 , where I logged in as Admin='Y' before, it changes it to Admin='N'  and all the selection (Customer, location and Room) has changed to that of machine 2.

What should I do. Please help.

Thanks in advance.
I need to copy a table from the main Access database and insert it into another database that is located in a different folder. I am programming in VB.Net. Below is the code I am trying. It gives me an error message at the "cmd.ExecuteNonQuery()" statement.

The error says:  {"Query input must contain at least one table or query."}. I have a database at the external folder location called AssetDatabase.accdb into which I want the table copied. What am I doing in correctly? Is the syntax wrong?

cmd = New OleDbCommand("Select * INTO  [tblAssetData-" & CompanyName & "] IN C:\Users\rkvjr\Documents\Backup\AssetDatabase.accdb FROM tblAssetData", objcon.con)

Open in new window

Enroll in June's Course of the Month
Enroll in June's Course of the Month

June's Course of the Month is now available! Every 10 seconds, a consumer gets hit with ransomware. Refresh your knowledge of ransomware best practices by enrolling in this month's complimentary course for Premium Members, Team Accounts, and Qualified Experts.

Is there a way to programmatically convert a text file to an excel spreadsheet?
hi all
i want a line per ittem, please help

ObjSendMail.HTMLBody = "Nombre:" +" " + Request.Form("fname") & Chr(10) & "Email:" +" " + Request.Form("email") & Chr(10) & "Consultorio:" +" " + Request.Form("consultorio") & Chr(10) & "Comentarios:" +" " + Request.Form("message")

Open in new window


I have a form form1 with a datagrid. But i call a second form form2 to made a query, to return only some records. I need to return a datatable to form1 and automatically fill a datagrid.
What is the best way to return a datatable from form2 to form1.

best regards
Is there a way to use WMI CONNECTION Crendentials once in a class I don't understand to code in clases just code in Form1. And also Am I closing the WMI Connection properly m = Nothing below is Source Code. I'm getting the message Get rid of IDE0017 VB.NET Object initialization can be simplified I'm creating a WMI Inventory app. Anyway any source code that is better then my Code I would appreciate cause I'm not a Professional Coder by any means but it is fun.
 Public Sub ListDrives()

        Dim options As ConnectionOptions
        options = New ConnectionOptions
        options.Username = "XXXXXX"
        options.Password = "XXXXXXXXXX"
        '* Test the connection

        '  Dim ps() As Services

        lvProcesses.Columns.Add("", 100, HorizontalAlignment.Left)
        lvProcesses.Columns.Add("Drive Letter", 120, HorizontalAlignment.Left)
        lvProcesses.Columns.Add("Drive Size", 120, HorizontalAlignment.Left)
        lvProcesses.Columns.Add("DriveFreespace", 120, HorizontalAlignment.Left)
        lvProcesses.Columns.Add("FileSystem", 120, HorizontalAlignment.Left)
        lvProcesses.Columns.Add("UNC Path", 200, HorizontalAlignment.Left)
        On Error Resume Next
        Dim scope As ManagementScope
        scope = New ManagementScope("\\" & ComputerName & "\root\cimv2", options)

        Dim query As ObjectQuery
        query = New ObjectQuery("SELECT * FROM 

Open in new window

I cannot seem to get FedEx Tracking API to work at all.

I reviewed the API and have been trying to get the examples to run.  However when I try todo this I get a lot of errors.  I am trying to build a simple Package Tracking page but the FedEx API is not documented in a way that I can use.

Any help would be great!  

When using the FedEx example code when i run the application i get this error.

An unhandled exception of type 'System.InvalidOperationException' occurred in System.Xml.dll

Additional information: Unable to generate a temporary class (result=1).

error CS0029: Cannot implicitly convert type 'TrackWebServiceClient.TrackServiceWebReference.NotificationEventType' to 'TrackWebServiceClient.TrackServiceWebReference.NotificationEventType[]'
I am using desktop.
How to have excel like filtering in datagridview.

Hey I am really struggling with this one. I can use a comma delimited file with no problem in my application I am building. But when I try to use a tab delimited file all I get is one column. The comma delimited worked. The rest did not. Can anyone tell me what I am doing wrong????

Dim Delimiter As String = ""
        If Me.cbDelimiter.Text = "," Then
            CSVConn.ConnectionString = ("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + Path.GetDirectoryName(FileName) + "; Extended Properties = ""Text;HDR=YES;FMT=Delimited""")
        End If
        If Me.cbDelimiter.Text = "|" Then
            CSVConn.ConnectionString = ("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + Path.GetDirectoryName(FileName) + "; Extended Properties=""text;HDR=YES;FMT=Delimited(|OrdersTAB.txtOrdersTAB.txt)""")
            ' Delimiter = "FMT=Delimited(|)"
        End If
        If Me.cbDelimiter.Text = "Tab" Then
            '= "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyDir;Extended Properties='text;HDR=YES;FMT=CSVDelimited;'; "
            'CSVConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Path.GetDirectoryName(FileName) + ";Extended Properties='text;HDR=YES;FMT=Delimited;'; "
            'CSVConn.ConnectionString = ("Provider=Microsoft.Jet.OleDb.4.0; Data Source = " + Path.GetDirectoryName(FileName) + "; Extended Properties=""text;HDR=YES;FMT=TabDelimited""")
            '  Delimiter = "FMT=TabDelimited"
I am trying to merge word document  from
Please find the code :
                                                        ReplaceWith:=StrRoomRouting & " #" & StrRoomNo, Replace:=Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll, MatchCase:=True)

Open in new window

I get an COM error:

String parameter too long
StrRoomRouting & " #" & StrRoomNo, this is  a long string more than 255

I had this question after viewing VB .Net - web browser control.  Automate clicking on and manipulating popup windows after downloading .exe file.

Basically, I am trying to do almost the same thing but I don't want to wait for the "Choose File to Upload" window to load. Instead, I'd like to:

1) Wait till the window becomes available
2) Automatically hide the window and send it back once it becomes available by intercepting the opening of that window
3) Set the file location to the file upload window in the background
4) Once set, click the "Open" button (like how it is being done now)

Could someone please provide some code on this scenario as I really need to get this working.

Announcing the Most Valuable Experts of 2016
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

I have a problem serialializing xml

I do not get all 3 values of 'liggingen' back in the object. I only get the first value. I tried to make a list, but no success.
What is the error in the user defined object?

This is part of the user defined object
Public Class MatenEnLigging
        Public Liggingen As Liggingen
        Public Inhoud As Integer
        Public Oppervlakte As Integer
End Class

Public Class Liggingen
        Public Ligging As String
End Class

And this is part of the XML
        	<Ligging>aan bosrand</Ligging>
            	<Ligging>aan rustige weg</Ligging>
	        <Ligging>beschutte ligging</Ligging>

Open in new window

Hi All,

I have query below:

dblSaldoAwal  is double
dblSaldoAwal   = 65422115.24 at debugging,

    sbdSQLCommand.AppendLine(", CAST(" & dblSaldoAwal & "AS MONEY) AS Debet")

The query return

, CAST(65422115,24 AS MONEY) AS Debet

Why it turns 65422115.24  to  65422115,24  ?

What's wrong ?

Thank you.

How can I set a variable in JavaScript on an ASPX page but also have the contents available in the VB.NET code behind? This is for an ASP.NET 4 and VB.NET

I can set the variable in the JavaScript but it's not available in the code behind.

I can set it something like this:

 function SetUserName() {
            var myvar = document.getElementById('<%= TextBox1.ClientID %>').value
            '<%Session("LastName") = "' + myvar + '" %>';
            alert('<%=Session("LastName") %>');

Open in new window

But when I try to get it from the code behind using like an Intermediate window I get like:

Session("LastName")  I like "' + myvar + '"

The alert is above in the javascript is showing the right thing. But that setting it apparently only happening on the ClientSide. How do/can I get it to happen on the client side but also on the server side or can I? Is this where Ajax come into play?

If so, how would something like that be done?

Any information would be greatly appreciated.

How do I modify the code below to convert dates to Day-Month-Year (i.e. 06 Dec 2016). I need to month to be in letters not numeric as the code below converts to.

result = DateTime.Parse(xnode.InnerText).ToUniversalTime().Date.ToString("dd/M/yyyy")


I am doing CSV upload on and its taking more than 1 hour to upload, So I has set sessiontimeout as 2 hour, I have set time out in below places:
1) In web.config :<sessionState timeout="120"></sessionState>
2) In web.config: <httpRuntime maxRequestLength="1048576" executionTimeout="7200" />
3) In .aspx page :     <asp:ScriptManager ID="scrpt1" runat="server" AsyncPostBackTimeout="7200">
4) In IIS: Application Pool have sesstion timeout as 120min
5) In IIS: In Website Advance setting set session timeout as 120 min.

   Still my page get blank after 1 hour and If i try to refresh then it shows Session Timeout, However my CSV Upload continue to work on database and it completes all upload in database in 2hour but Page get expired. Please help asap.

   FYI I am using IIS 7 on Windows server 2008 machine.

I have installed a C++ add-on to Visual Studio that enable code to be developed for Particle Electron and Photon devices. I have an issue that I believe is more related to Visual Studio than the plug in.
First I installed the plug-in on my home PC (running Windows 10, 64 bit OS) and VS 2015. All worked fine.
I then copied the same steps on my office PC (also running Windows 10, 64 bit OS) and VS 2015 but when I attempt to create a project I get no option to enter solution name or location and the checkbox to create a directory is also gone. When I proceed, I get a project but no solution and then I can never save the project. I can only exit VS if I discard the project.

Visual Basic.NET




Articles & Videos



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,

Top Experts In
Visual Basic.NET