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,


Convert a format of string from fromat MM-dd-yyyy to dd-MM-yyyy

I have an Excel add-in firing an HRESULT 0x800401A8 error, when calling the getter of Worksheet.Parent.

I would be glad if anyone could let me know what the error might be, but more importantly and more generally, I would like to know how I can understand these HResult codes?

I did the following but am still confused:

Read the Microsoft's documentation on the Structure of COM error Codes.
Checked this SO thread.
Tried my chances with Magnum DB.


I am working on an application to access data via API using VB.NET.

I have so far managed to request for and retrieve a security token in the format as shown below:


I need to retrieve the "token" value and use that to access the server and request specific information.

I have created a class

Public Class SecurityToken

    Public Property Success As String

    Public Property Token As String()

End Class

And in my code, I successfully get to this point where I get the result as shown above

Dim dataStream As Stream = response.GetResponseStream()
Dim reader As StreamReader = New StreamReader(dataStream)
Dim responseFromServer As String = reader.ReadToEnd()

I am stuck at this point in trying to split the result and retrieve just the token to use in further processing.

Any help would be appreciate.

Thank you.

I have a project to convert 1000's of tif images to pdf. In order speed up the process i'm trying to use a thread pool.

The code below loops through all the directories/files but only converts a few hundred files (no errors).

I think the issue is how I have implement the threading. Can you enlighten me on the correct threading method?

Imports System.IO
Imports System.Threading
Imports GdPicture14

Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ' Get recursive List of all files starting in this directory.
        Dim tifFiles As New List(Of String)
        Dim folderStack As New Stack(Of String)
        Dim fileStack As New Stack(Of String)
        Dim currFile As String = ""
        Dim Count = 0
        Dim w As WaitCallback = New WaitCallback(AddressOf cvt1)
        Do While (folderStack.Count > 0)
            ' Get top directory string
            Dim dir As String = folderStack.Pop
                ' Add all immediate file paths
                If Not Directory.Exists(dir.Replace("C:\", "D:\")) Then
                    Directory.CreateDirectory(dir.Replace("C:\", "D:\"))
                End If
                For Each file In Directory.GetFiles(dir, "*.tif")
                Do While (fileStack.Count > 0)
                    currFile = …
On a Datagridview when I select NEW field I want it to populate the name in the grid from a text box above on the same page.
I'm trying to use the latest release of Microsoft Visual Basic to play a WAV file.  I want to loop the audio.  Is there a way to do this without a noticeable gap?  Is there a library available that can do this?
Hello, all.

I have these two commands

Example insert

{Something here} {{Something else here}}

Open in new window

Dim Regex2 As Regex = New Regex("\{.*?\}")
Dim Regex4 As Regex = New Regex("\{{.*?\}}")

Open in new window

They do not produce any errors, however.
The single { }
Will insert into the database for the {{ }}
In the database, you will see
{Something here}

Open in new window

With the curly brackets around it.

How can I distinguish between the two commands, so that only the double curly's will insert into its column, and the single curly will only insert into its column?

I am brand spanking new to ASP.NET MVC and I'm working through a tutorial to get the basics. The tutorial is in C# and I'm converting it to VB to stay consistent with some related projects. I have to assume that I'm missing something in that conversion but can't figure out what it could be.

I have the following class:

Public Class GuestResponse
    Public Name As String
    Public Email As String
    Public Phone As String
    Public WillAttend As Boolean?
End Class

Open in new window

and a strongly-typed view related to that class:

@ModelType PartyInvites.GuestResponse

    Layout = Nothing
End Code

<!DOCTYPE html>

    <meta name="viewport" content="width=device-width" />
    @Using Html.BeginForm
        @<p>Your name: @Html.TextBoxFor(Of String)(Function(x) x.Name)</p>
        @<p>Your email: @Html.TextBoxFor(Of String)(Function(x) x.Email)</p>
        @<p>Your phone: @Html.TextBoxFor(Of String)(Function(x) x.Phone)</p>
            Will you attend?
            @Html.DropDownListFor(Of Boolean?)(Function(x) x.WillAttend,
                                                        New SelectListItem() {New SelectListItem With {.Text = "Yes, I'll be there", .Value = Boolean.TrueString},
                                                        New SelectListItem With {.Text = "No, I can't come", .Value = Boolean.FalseString}}, "Choose an option")
        @<input type="submit" value="Submit RSVP" />
    End Using

Open in new window

My controller has a simple action method that takes that class and responds with another view:

Function RsvpForm(g As GuestResponse) As ViewResult
    'TODO: Email response to the party organizer
    Return View("Thanks", g)
End Function

Open in new window

Unfortunately, the form data from the post request isn't being populated in my GuestResponse class. If I insert a breakpoint in that action method, all the GuestResponse properties are empty. At the same time, the Request.Form values look as expected - they're just not filling in the GuestResponse object.

I'm sure it's something small I'm missing. Any help is appreciated.
I have an application in VB.Net using a connection via ADODB.connection.  We are in the process of moving our "stuff to the cloud".  The new server is Server 2016 and the database is SQL Server 2008 Express.  I have enabled the protocols in SQL Server for Named Pipes, TCPIP.  It appears that I have the Server/Database/User/Pwd info correct, but the connection object is not supported?

The connection string is similar to this:
"Driver={SQL Server};Server=SQL1\SQLEXPRESS;Database=Orders;UID=sa;pwd=Adg991!; providerName=System.Data.SqlClient"

Thanks for you help!
I have an interesting situation. I have a URL that returns data based on a 'search' parameter within the URL.. example: dvd_search.php?type=title&search='SomeData'

The Website has different areas that can be searched. Each are is accessed by 'clicking' a button (link) that takes you to that particular Page. From there you can query for data that is related to that Page/category.

The interesting part of this that the actual resulting URL looks the same no matter which page you are on... except it will only return data that is apropos to the page you are on.

I am trying to automate the Query process from within a VB.Net program and I am trying to use CURL to get the data into a file that I can parse.

I am not at all versed in the  use of CURL but I do know that this can probably be dome in CURL if I could figure out the proper syntax that would perform the desired function..

I am guessing here but I am assuming that the key to making this work is the 'Cookie' that is being generated, probably indicates which page 'I' am on and which 'Data Set' to use.

Any help is greatly appreitated.

Thanks in advance
C# code converted to VB. The problem is List.SelectedItems or, rather, my lack of understanding. The exception is:

Object reference not set to an instance of an object.

Public Function CommaDelimitedString _
        ByRef List As ListBox
    ) As String

         Dim returnString as string

            For Each ListBoxItem In List.SelectedItems
                Dim DataRowView As Object = Nothing
                Dim drwItem As Object = Nothing

                If drwItem Is DataRowView Then 'Check Then If the Then item can be cast To your Class
                       ' build string
                End If
  return returnString

I'm drawing a blanks on this. What am I missing? Thanks for any help.
original error causing showing upHello,

A strange problem popped up on Visual Studio 2019 today.  Both Projects were created recently in VS2019

1) Project A built and working no problem on my machine and everyone else's machines.  It includes a reportview v 15.0.
2) Project B needed a new report made but I wanted to make it a local report (populated with data that was already queried and brought down from the server and residing in a dataset).  I couldn't remember how to do this so I was fiddling with some of the settings in VS 2019 for THAT project and THAT report.  So I thought...

3) When I return to Project A I get a "required privilege is not held by the client" error when executing the reportviewer1.refresh command.  Everything else in the program seems to be working fine.  Earlier versions of Project A produce the same error BUT ONLY ON MY COMPUTER.  Everybody elses works just fine.  I broke something somewhere but I have no idea where to start looking.

Any ideas are welcome.  I've already flushed out the bin, reset VS settings, Reloaded the reportviewer references, and now the project won't build at all.  Got worse as I tried to fix it....

Hi Experts,

I'm trying to build in some error handling to tie the script below together and am stuck, any help with this is appreciated.

Issue:  for any computers that are offline, I'm getting RPC unabilable errors and these continue to process through the loop

Here is what I'm trying to accomplish:

1.  For error handling, is there a way to have a function determine whether the computer is up or not >  then return $true or $false and put into a condition for if.  If it's not up, is there a way to pause until it responds or break out of the loop for just that computer?  If it's up, then do patching/install functions in the workflow.

2.  In the process-monitor function (6) - I wanted to log into the .csv if this was online or offline.

3. I wanted to incorporate a function that checks for any missing or pending updates to determine if the workflow needs to be processed. (I left (2) empty for this), not sure how to accomplish this and then condition.  Here are the queries:

get-wmiobject -query "SELECT * FROM CCM_SoftwareUpdate WHERE ComplianceState = 0" -namespace "ROOT\ccm\ClientSDK"  #which updates are missing:

Open in new window

(get-wmiobject -query "SELECT * FROM CCM_SoftwareUpdate" -namespace "ROOT\ccm\ClientSDK").name  #show needed updates

Open in new window

-Then if the above are true, trigger all, which I have in (5):

([wmiclass]'ROOT\ccm\ClientSDK:CCM_SoftwareUpdatesManager').InstallUpdates([System.Management.ManagementObject[]] (get-wmiobject -query 'SELECT * FROM CCM_SoftwareUpdate' -namespace 'ROOT\ccm\ClientSDK'))

Open in new window

Here is what the script does, I've numbered all functions in order:
1 - Test-Connection
2 - detect missing/pending
3 - detect pending reboot
4 - run advert
5 - invoke all updates
6 - process monitor
6a - call from within process monitor function to send email


Open in new window

Hey Folks

Quite stuck here.

I have a VS VB WinForms App.
I have added a datagrid and got data pulling from my SQL server etc...

It is bound as I understand it bc of this. I have loaded via design and programatically exploring all of the options.

Right now I have a LOAD button so going programatically.

However, for the life of me I cannot get any new data entered directly into the Grid to save and reload.

I have tried numerous things, so please advise what SHOULD work. Incase in my mucking about I have incorrect set something etc...

Many thanks in advance

WRiting code in visual studio vb to declare a variable that will store the cost of bananas per pound
Do u know any way to develop something like DocuSign? Especially we can drag and drop for signature request ?
I have a windows form that uses filters on the on [bindingsource]
I am trying to get a search criteria that is found anywhere in a string to return in the filter results.
[exisiting code] Master_ContactsBindingSource.Filter = "c_company = '" & InStr(CompanySearch.Text, 1) & "'"

The problem is that I receive no results (and does not error either) for terms that I know are in the table such as "son".

The desired result is to return all records that contain the search term "son" but clearly I have this wrong.

c_company = [table field]
[CompanySearch.text] is the textbox with the search term

Hello Experts,
My app reads a text file
and inside this text file, data can have special characters like á  é  í ó ú ñ Ñ

When visual basic reads this file, these special characters are interpreted as a black character.
How can I fix this?

Here is the piece of code I am using.
        Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(filename)
            MyReader.TextFieldType = FileIO.FieldType.Delimited

            While Not MyReader.EndOfData
                    For a = 1 To 15
                        currentRow = MyReader.ReadFields()
                        For Each currentField In currentRow
                            D1(a) = currentField
                    Next a
                Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
                    MsgBox("Line " & ex.Message & "is not valid and will be skipped.")
                End Try
                Exit While
            End While
        End Using
Hello All;

I have been using the ID3v2 component, ID3TagLibrary, to read the metadata of MP3 files uploaded to my server for a few years now.
And I just found out it will not keep the text format. Example.
It will take this
And change it to

I need a component that will NOT mess up the formatting of the text.
Any and all ideas will be greatly welcomed.

Thank you.
I upgraded a local Access table to a remote SQL 2017 database.
1. The connection reads data but
2. The connection won't write data.
If I use the same User and Password I can change (update) data within the SMS

I use a front end and all was working great with MS Access locally

I use a SAVE button after making some data changes and I receive an error 5 which I have not been able to resolve. I've pasted the code behind the SAVE button below.

        'Master_ContactsBindingSource.Filter = "email = '" & mTempEmail & "'"
        Me.Cursor = System.Windows.Forms.Cursors.Default

Here is the connection string (READ=great, write = NO
Provider=SQLNCLI10.1;Data Source=;Initial Catalog=Data_Warehouse;User ID=dw_admin;Password=***


Thank you,
Hello All;

As the title suggests, I have just installed SQL Server 2019 on my test system, in hopes that I can get it to accept the Case-insensitive and accent-sensitive characters like the example below.

Dvořák Hall

So far, when I insert these characters, I get a BIG Y from the >> řá <<

Table column information

The column is set to ( CHAR )
Collation = Latin1_General_100_BIN2_UTF8

In my web.config file, I have the following.

<?xml version="1.0" encoding="UTF-8"?>
	<globalization requestEncoding="utf-8" responseEncoding="utf-8" />

Open in new window

Any additional information would be wonderful.
Hi Experts,

How can I use to access information about installed applications based on the information displayed in Control Panel / Programs and Features?

Here's a screendump showing the Name, Version and Location fields that I am after:

information about installed applications based on Control Panel / Programs and Features

I have the following loop that I want to continue until every line in SR (StreamReader) has been read and outputted. What condition should I add to the Do While Loop to have it read all the lines?

        Do While (strLine ???)            
            strLine = SR.ReadLine                               '// Read in line
            If strLine Is Nothing Then
                MessageBox.Show("Unable to extra data, please try again. If it continues to fail, please contact Brian L.")
                Exit Sub
            End If
            '// Output line when it contains useful info
            If strLine.Contains("Gi") Then
            End If

Open in new window

I need to get the value of a combobox when the user is selecting a new value.  I want the original value and what it was changed to.

I've been researching but have not found a solution.

Any ideas?
Hi experts,
I have wrote the C# API programe to get data from different location.
All used to work fine.Suddenly it's generating error becuase the records not available
in the API records.(requesting records)There is no way to find Candidate avaiable or not.

see below link how the API request send.



 500 Internal Server Error
    "error": {
        "type": "getStreamError",
        "message": "there was an unknown error getting candidate stream."

 string urlCandatestream = "/company/" + CompanyID + "/position/" + positionID + "/candidate/" + candidateID + "/stream";
                var request = new RestRequest(urlCandatestream, Method.GET);

                request.AddHeader("Content-Type", "application/json");
                request.AddHeader("cache-control", "no-cache");
                request.AddHeader("authorization", connectAPI.getAccessToken());
                // rqst.Proxy = GlobalProxySelection.GetEmptyWebProxy();

                IRestResponse response;
                varRequest = request.ToString();
                    response = await _restClent.ExecuteTaskAsync(request);
                    VarRequestResults = response.Content;
                catch (Exception ex)
                    throw new Exception("Error executing  request to " + 

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,