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 using listview as WinForm control in my application. I'm using a single column list type but the problem is FullRowSelect property doesn't work with my application.

listView1.FullRowSelect = true

Open in new window

Does anyone has experience how can i use FullRowSelect feature?
How to use TreeView navigation  in correct approach. I'd like to use two vertical panel and make the left one as TreeView navigation panel and i'd like to show content on the right panel according to choosen node.

I searched some possible ways but i don't know which one is efficent and logic for programming approach.

1) Creating different forms without borders and when user select the node it will add that form to right panel. Like;

Dim f as Form
f = New frmNewForm
f.TopLevel = false


2) Adding panels with controls to MainForm's main panel(right panel) and make visible/invisible the panels according to selected node.

These are coming my mind at first. If you have experience about this topic could anyone help and guide me which method is suitable for it.

Note: I'll have apprx. like 15-20 navigation panel.


I am trying to retrieve loop a series of records as dates, the field eventDate is set to smalldatetime but I receive an error:

ex = {"Conversion from type 'Date' to type 'Long' is not valid."}

Open in new window

Public Function GetDisabledDates() As IEnumerable(Of DateTime)
        Dim disabledDates As New List(Of DateTime)()

'This works if added statically
        'disabledDates.Add(New DateTime(DateTime.Today.Year, DateTime.Today.Month, 7))

        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("ProjectConnectionString").ConnectionString)
        Dim cmd As SqlCommand = conn.CreateCommand()
        cmd.CommandText = "SELECT * FROM [tbl_DisabledDates] WHERE [eventDate] >= @Date"
        cmd.CommandType = CommandType.Text

        cmd.Parameters.AddWithValue("@Date", Today)

        Dim reader As SqlDataReader = cmd.ExecuteReader()


            While reader.Read()
                disabledDates.Add(New DateTime(reader("EventDate")))
            End While

        Catch ex As Exception
        End Try


        Return disabledDates

    End Function

Open in new window

Any help is appreciated.
I have a application that is dealing with clients bank accounts, I am trying to import a csv bank statement but obviously every statement is different.So to just look at a Comma Separated Value is great but there are also some banks IE that put commas in their descriptions.

Can you help below is the basic import i use:

        Dim fName As String = ""
        OpenFileDialog1.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
        OpenFileDialog1.FileName = ""
        OpenFileDialog1.Multiselect = False
        OpenFileDialog1.Filter = "Comma-seperated Values|*.csv"
        OpenFileDialog1.FilterIndex = 2
        OpenFileDialog1.RestoreDirectory = True
        If (OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK) Then
            fName = OpenFileDialog1.FileName
        End If
        Dim TextLine As String = ""
        Dim SplitLine() As String
        dgBR.ColumnCount = 9
        dgBR.Columns(0).Name = ""
        dgBR.Columns(1).Name = ""
        dgBR.Columns(2).Name = ""
        dgBR.Columns(3).Name = ""
        dgBR.Columns(4).Name = ""
        dgBR.Columns(5).Name = ""
        dgBR.Columns(6).Name = ""
        dgBR.Columns(7).Name = ""
        dgBR.Columns(8).Name = ""
        Dim Allocate As New DataGridViewButtonColumn
        If System.IO.File.Exists(fName) = True Then
            Dim objReader As New System.IO.StreamReader(fName)
When I right click on my form in the Solution Explorer and choose "View Code", I get a blank screen (dark blue window) that I cannot type into. Even when I click on "View Windows Settings", the app.manifest comes up completely blank.  I'm thinking it's because I ended up deleting the initial Form1 and then created a new form. I had to change the Startup form to my new form, but maybe I needed to update the form name in other places?
I'm using a one of scientific program COM interface in my tool.

I got some string outputs which i get from program, but i'd like to classify them according to it's structure general structure is "MATHNAME(VALUES)" but in here VALUES also have several values which are seperated by comma. I also would like to classify them but dont know how to do that.

Some Example String Outputs I get and how i get informations from it.

FX(a)  --> Name:FX, Value1:a
FORCEOV(a,b) --> Name: FORCEOV, Value1:a, Value2:b
CONSTRCF(a,b,c)--> Name: CONSTRCF Value1:a, Value2:b Value3:c
ANGLE2TRMAT(a,b,c,d,e) --> Name:ANGLE2TRMAT, Value1:a, Value1:b, Value3:c, Value4:d, Value5:e

Open in new window

I'll write them to text box later but first i'd like to get math function name and get values inside parenthesis which are divided by comma. Can anyone help me  how can i organize it sufficient way of coding?

How to seperate this string "ANGLE2TRMAT(a,b,c,d,e) " to example like above.
ANGLE2TRMAT, a, b, c, d, e
Need a module to merge PDF's
is any idea or some freeware that achive that, we can't purchase several PDF pro licences only for that propouse.
Pleas help me out you experts!
I have an event for my datagridview currentcelldirtystatechanged, because when i'm selecting a item from my DataGridViewComboboxCell and run another method before commit it it returns nothing so i found a solution with below code;

    Private Sub CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) Handles dgvList1.CurrentCellDirtyStateChanged
    End Sub

Open in new window

But i have several datagridviews to do that same eventhandler. Is there a way yo use a single Sub to handle other datagridviews for Dirty State Changed.

I am converting an old VB6 program to VB.NET. I have a lot of it converted and working.. However I occasionally run into situations that elude and I need additional assistance. I am at another one of those junctures.

I am now working on the FTP portion of my code. Admittedly the previous VB6 code only required the 'DownLoad' properties and so it has worked fine for many years. I googled several  solutions but I am still having trouble getting files up to my server.  I can access the server with FileZilla and I can also upload files from a 'Command Window' via FTP as well. The code I currently have fails with the Following error: "System.Net.WebException: 'The remote server returned an error: (553) File name not allowed.'" I am using Visual Studio 2017 Express.

The files I am trying to upload are image .JPG files and the names of the files are all digits except the extension. Maybe someone can spot where I went wrong...


        Dim ftpRequest As FtpWebRequest = CType(WebRequest.Create("" + ThisUPC + ".jpg"), FtpWebRequest)

        ftpRequest.Method = WebRequestMethods.Ftp.UploadFile

        ' Confirm the Network credentials based on the user name and password passed in.
        ftpRequest.Credentials = New 

Open in new window

I have an ASP.Net webforms app with a GridView.  (The Gridview automatically generates the columns on binding because the data source is dynamic and the number of columns vary.)

I have code in place so when a cell in the GridView is clicked by the user it will display some data relative to the clicked cell in a Panel via the ModalPopupExtender control (from AJAX control toolkit).

The problem I have is the ModalPopupExtender fires BEFORE the GridView_RowCommand.   I need to run a query in the GridView_RowCommand event to collect the data to populate the labels in the Panel control, that is displayed via the ModalPopupExtender.   The query needs to run in the GridView_RowCommand event because this is where I get the needed Row and Cell index data for the query.

How do I get the ModalPopupExtender to fire AFTER the GridView_RowCommand event?

ASPX code (Pertinent):

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

    <style type="text/css">



        background-color: Black;
        filter: alpha(opacity=90);
        opacity: 0.8;




        background-color: #FFFFFF;
        border-width: 3px;
        border-style: solid;
        border-color: black;
        padding-top: 10px;
        padding-left: 10px;
        width: 300px;
        height: 140px;



                        <asp:GridView ID="grdKanban" runat="server" 

Open in new window

In, how can I get a reference to a property of a specific instance of an object?

I know I can do something like this

            Dim P As PropertyInfo
            P = Me.GetType.GetProperty("acRecordSource")


But how can I save a reference to *this* property of *this* instance so anywhere in my code I could type:


and get the value of Property P for instance Me?  (Because varP refers to the "acRecordSource" property of instance Me?

I found this code to compile and execute code in runtime:

 Dim entrada As String


            entrada = My.Computer.FileSystem.ReadAllText("Codigo1.txt")
        Catch ex As Exception
            MessageBox.Show(" Erro : " + ex.Message)
        End Try

        Dim codigo = <code>
                       Imports System
                       Imports System.Windows.Forms

                       Public Class TempClass
                           Public Sub ResultadoTexto(ByVal txtOutput As TextBox)
                               <%= entrada %>
                           End Sub
                       End Class


            Dim vbProv = New VBCodeProvider()

            Dim vbParams = New CompilerParameters()

            vbParams.GenerateExecutable = False

            vbParams.GenerateInMemory = True

            Dim resultadoCompilacao = vbProv.CompileAssemblyFromSource(vbParams, codigo.Value)

            If resultadoCompilacao.Errors.Count > 0 Then

                For Each er In resultadoCompilacao.Errors

                Dim obj As Object = 

Open in new window


What is the coding difference between c# and
I am looking from syntax point of view.
Any suggestion are appreciated.

I am starting to use vbconversions software to translate some of my vs2008 projects over to c#.  These projects have been running for years on Symbol/Zebra scanners, and vs2008 is as high as I can go while developing apps for these devices.

vbconversions software is a paid subscription, and so far seems to do a very good job.  In the most recent conversion, I'm getting two errors that I need help with.

The code I've been using to play .wav files is:

    'This is the setup to make the PlaySiren sub work, to play a .wav on the scanner for errors...
    Public Class win32
        Public Declare Function PlaySoundW Lib "coredll.dll" Alias "PlaySoundW" (ByVal lpszName As String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer
        Public Const SND_FILENAME = &H20000
        Public Const SND_ASYNC = &H1
        Public Const SND_SYNC = &H0
    End Class

...and there is a line at the top of the module that says "Imports System.Runtime.InteropServices".

Someone gave me this code years ago to play .wav files on the scanners, but I must admit I don't understand what all is being done here or how this works.  I may have come from an e-e contributor long ago.

Then when vbconversions did the translation to c#, it created this code:

            //This is the setup to make the PlaySiren sub work, to play a .wav on the scanner for errors...
            public class win32
                  [DllImport("coredll.dll",EntryPoint="PlaySoundW", …
I had this question after viewing Concurrency Violation Error.

Using Vb.Net and VS2017. I am trying to update a SQl table and everything works fine when I test the code with a variable (integer) set to a number that is in the table as a PK. However, when I load the same variable with the PK taken from either the datagridview (DGV) column or the dataset that fills the DGV I get a concurrency violation error. Single user so no update violations. The update are carried out with parameters. Here are some snippets of code.

This works
 ' Create the UpdateCommand.
        DiD = 137 ' This works
        sqlString = "UPDATE Data SET  PaidIn = @PMPaidIn WHERE DataID =@DiD"
        command = New SqlCommand(sqlString, connection)
        command.Parameters.Add("@DID", SqlDbType.Int).Value = DiD
        command.Parameters.Add("@PMPaidIn", SqlDbType.Decimal).Value = PMPaidIn

        adapter.UpdateCommand = command

Open in new window

but when I do this

Private Sub DgvData_CellValueChanged(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DgvData.CellValueChanged

        If e.RowIndex < 0 Then Exit Sub
        row = e.RowIndex
        DiD = dts.Tables(0).Rows(row).Item("DataID") ' When debugging this DataID is 137 but violation occurs
more code load the variables for other columns
End Sub

Open in new window

I have checked GetType() of the DiD variable and DataID
The following visual basic code fails to run.

       Dim srce As String = "C:\Users\ZZZ\Documents\My Great Data\Audio"
        Dim dest As String = "T:\My Great Data\Audio"

        Dim MyProcess As Process

        MyProcess = New Process

            With MyProcess.StartInfo
                .FileName = "C:\Windows\SysWOW64\robocopy.exe"
                .Arguments = srce & " " & dest & " /S /E /M"
                .UseShellExecute = False
                .CreateNoWindow = True
                .RedirectStandardInput = False
                .RedirectStandardOutput = True
                .RedirectStandardError = True
            End With


However running the following PowerShell script works fine

robocopy "C:\Users\ZZZ\Documents\My Great Data\Audio" "t:\My Great Data\Audio" /S /E /M


I think the problem is the fact that the srce & dest contains spaces.

How can I make this work?
Anybody installed Visual Studio 2019 yet?

I plan to instal it in prep for a code camp, and wonder who else has it running.

Let me know.

Hi all.

I have a Chart object in my Visual Studio windows application, I'm using VB.NET.

The problem I'm running into sometimes is when some of the columns have really low values compared to other columns with really high values, for example, one stacked column will have a Y value of 50 and another stacked column will have a Y value of 1,000 then the 1,000 stacked column will be cut off at the top. I have 2 series, the first series is a stacked chart that sums up the sales for each product line and the second series is a line chart type which is a sum of all the stacked columns for each year. From my screen shot you can see that it's cutting of the second series (line chart). Any help would be appreciated!

Here's my code to load the chart:

Private Sub LoadChartProductLine()


Dim query As String = "SELECT ProductLine, SalesYear, Sales, TotalYearSales"
        query += " FROM CRMProductLineSales WHERE AccountID = '" & txtPMID.Text & "'ORDER BY ProductLine"
Dim dt As DataTable = GetData(query)

        If dt.Rows.Count = 0 Then
            Chart1.Visible = False
            Exit Sub
            Chart1.Visible = True
        End If

        'Get the DISTINCT product lines
        Dim productlines As List(Of String) = (From p In dt.AsEnumerable() Select p.Field(Of String)("ProductLine")).Distinct().ToList()
        Dim years As List(Of Integer) = (From p In dt.AsEnumerable() Select 

Open in new window

I have a project written in VB.Net. My updates to the SQL Server are working fine except when I restart my project all changes are lost. After a lot of searching I found that I have to change 'Copy to Output Directory' to 'Copy if Newer' or 'Do Not Copy' (depending which site I read) in the properties of the database in Solutions Explorer. I can change the Copy to Output in properties of the form but I don't have the database in my Solutions Explorer. Totally lost and confused. I am teaching myself from VBA to VB.Net.
Any help would be appreciated.
How can I take advantage of the WPF rich design content inside a project. I am looking to create a cool splash screen with a login screen using WPF.
The question I have because I have not played with WPF inside a application what issues would this cause and is it even recommended?
I am working on a app that that two dropdownlist that autopostback.  My problem is when selecting my reset button
the autopostback dropdownlist does not reset. I am using a javascript in an attempt to reset the dropdownlist.

All other fields in the form reset except the dropdownlist and capthcha as well once the capthcha accepts the page.

There is a masterpage as well.

Any clues?


<div class="form-group">
                    <div class="col-xs-12 col-md-8 col-sm-10 nill">
					    <asp:Label ID="lblSubject" runat="server" AssociatedControlID="ddlSubject" Text="Subject *" CssClass="control-label" />
					    <asp:DropDownList ID="ddlSubject" CssClass="form-control" runat="server" aria-label="Subject" required="required"  AutoPostBack="true" EnableViewState="true" OnSelectedIndexChanged="ddl_SelectedIndexChanged">
						<span class="required"></span>
                  <div id="divQuantity" class="form-group" runat="server" Visible="false">
                       <div class="col-xs-12 col-md-8 col-sm-10 nill">
                       <asp:Label ID="lblQuantity" runat="server" AssociatedControlID="ddlQuantity" Text="Medicine Disposable Bags *" CssClass="control-label" />
                        <asp:Dropdownlist  ID="ddlQuantity"  CssClass="form-control" runat="server"  aria-label="Medicine Disposable Bags" required="required" AutoPostBack="true" 

Open in new window

Greetings.... OK maybe a somewhat embarrassing question...

I am New to Visual Studio 2017 and all of it's nice new features. I have started on VB.NET a program/application and got some of the functionality done. I wanted to make sure that I could 'Deploy' the  program easily so I installed the 'Installer' package into VS 2017. I was successful in getting an .msi package created and working. (everything worked).

I have since continued to work on the Main program and in the process have created Files and Folders that need to be deployed along with all other executables and libraries..

Here is the embarrassing part,,, how do I RE-RUN the Setup Wizard in VS2017 so that I can add all the files and folders. I have done a lot of Google searches and have even searched EE but apparently I am "asking the wrong question" because so far I not found an information on how RE-RUN/REBUILD the Install package.

Please forgive me, I know there is probably an easy answer but so far it has eluded me...


Don't know if there is a solution like this, but I am looking for a software or tool that I can use to have the programmers collaborating in software development, history software versions, privileges to access codes, able to assign programmer to specific codes, possibility to have start/end-dates for each software to developed that has been assign, possibility to have at least 2 o 3 programmers work with the code simultaneously (and when done, the software tool would merge all changes into the code) and finally some sort of history of each code on who have worked on it, who started it, who finished it.  The programmers work with VB. Net.

Thank you very much for you help.
I need help with the following code.  Both SourceFile and TargetFile contains spaces.  How do I make this work?  Currently it does nothing.

    Dim RoboCopyArgs As New StringBuilder

    With RoboCopyArgs
                        .Append(" ")
                        .Append(" /S /E ")
                    End With

                    Dim proc As Process = Process.Start("C:\Windows\SysWOW64\Robocopy.exe", RoboCopyArgs.ToString)


I am trying to write code that will determine the resolution of the screen the user is using in order to properly size charts.  I am having trouble getting anything to work. Can someone please help? I am using ASP.Net chart control and

Following is code that does not work.

Thanks for the help.

Dim CurScreenWidth As Integer = Screen.PrimaryScreen.Bounds.Width
        Dim CurScreenHeight As Integer = Screen.PrimaryScreen.Bounds.Height
        Dim DesignWidth As Integer = 1680        
Dim DesignHeight As Integer = 1050 
        Dim WidthRatio As Single
        Dim HeightRatio As Single

        WidthRatio = CurScreenWidth / DesignWidth
        HeightRatio = CurScreenHeight / DesignHeight

        Dim ChartWidth As Single = DesignWidth * WidthRatio * 0.96         
Dim ChartHeight As Single = DesignHeight * HeightRatio * 0.85

Open in new window


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,