[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More


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

Can someone provide with some links on how to download FREE icons for Windows 10. I want to make sure that the provided link will allow me to download multiples at one time(20 or more) . I have come across a web site {IconArchive.com}but it would only allow me to download 1 at a time. If you can include instructions on DOWNLOAD I would greatly appreciate it if it is not included in the web site.
Thank you.

Basem Khawaja, R.Ph.
OWASP: Forgery and Phishing
LVL 12
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

I open reports of my project in internet explorer which are being made from string. Now i need to bifurcate my reports by detecting the new page so that margin could be set for each and every page.

In other words i wish to add multiple pages in a report but if my page has less data then i need to start the next page.

I am using vb.net windows application.

Thanks a ton in advance.
I would like to get some information from outlook. Basically, get the number of emails received every month, but not just for the current view (this is what my code does right now, fut for all subfolders, up to 2 depth). I have tried with this:

'The following codes are working to count by day
Sub CountReceivedEmailsbyDay()
    Dim objItems As Outlook.Items
    Dim objItem As Object
    Dim objMail As Outlook.MailItem
    Dim strMonth As String
    Dim dReceivedTime As Date
    Dim strReceivedDate As String
    Dim i, n As Long
    Dim strMsg As String
    Dim nPrompt As Integer
    Set objItems = Outlook.Application.ActiveExplorer.CurrentFolder.Items
    objItems.SetColumns ("ReceivedTime")
    strMonth = InputBox(“Enter the specific month.(Format: yyyy-mm)”, “Specify Month”)
    If strMonth <> "" Then
       n = 0
       For i = 1 To objItems.Count
           If objItems.Item(i).Class = olMail Then
              Set objMail = objItems.Item(i)
              dReceivedTime = objMail.ReceivedTime
              strReceivedDate = Year(dReceivedTime) & “-” & Month(dReceivedTime)
              If strReceivedDate = strMonth Then
                 n = n + 1
              End If
           End If
       Next i
       strMsg = "You have received " & n & " emails on " & strMonth & "."
       nPrompt = MsgBox(strMsg, vbExclamation, "Count Received Emails")
       nPrompt = MsgBox("Please input the specific month!", vbExclamation)
How do I do EagerLoading of this object
Public Class Person 
    Public Overridable Property personId As Integer
    Public Overridable Property nameType As String

   Public Overridable Property Names As IList(Of PersonNameType)

End Class

Public MustInherit Class PersonNameType
    Public Overridable Property personId As Integer
    Public Overridable Property nameId As Integer

    Public Overridable Property Person As Person
    Public Overridable Property Name As Name

End Class

Open in new window

I tried doing this but the navigation properties (Person/Name) of "Person.Names" is not getting filled. I mean when I drill into the Person.Names and one of the collection item the personId/NameId has data but the Person/Name properties has nothing. How do I fill that data in?

I have a Datagridview with 4 columns.

All columns are disabled apart from column 4(Index 3).

When a user finished entering data in cell 3 I would like it to tab to cell 3 in next row.

I have a windows form with a splitter control on it. The layout or the two split panes are Horizontal, so they appear to be stacked on each other.

The top pane has various controls in it. The bottom pane has a GridView in it.

 Now when the form displays my bottom pane in the splitter is much smaller in height compared to the top splitter pane/panel.
How can I control the size of the bottom default/pane/panel when the form is initially displayed?
Right now I have an export file being saved with a unique barcode that is attached to the export file. I would like to know how I can add a unique month and year to the file but if I have multiple data collected in the same month I would append that data until a new month.

For Each export In pFile.Exports
If newDir = String.Empty Then
If export.addVariableExportUniqueVIN Then
exportFile = New FileInfo(newDir & "\" & export.ExportName & ScannedBarCode & export.ExportExtension)
exportFile = New FileInfo(newDir & "\" & export.ExportName & export.ExportExtension)
End If
end if

Open in new window

My web page has the function to create 40 different pie charts for 40 different machines and their activity and display them after loading. However, I noticed that by doing so the page loading is much longer, takes about 30 seconds to finish loading.

At first I thought it was my SQL to get the data for 40 machines was the cause. But after copying it from the code and testing it, that was not true. Also, the page loads faster when I set my page to create a single pie chart, so I'm likely to assume that the large sum of pie charts to create is the cause for the slowdown.

 Sub draw_chart1() 'All Machines

        Dim check1, check2, fi, cnt

        Dim sql
        Dim myConnectionString As String = "Provider=SQLOLEDB;" & SQLDB_pp.ConnectionString
        fi = 0
        cnt = 0

        'Get all model
        Dim query1 As String = String.Format("SELECT DISTINCT A.MacID FROM dbo.tblMachine A LEFT JOIN  dbo.tblDataHdr b on a.MacID = b.MacID where DayID between '" & TextBox1.Text & "' AND '" & TextBox3.Text & "' ORDER BY A.MACID")
        Dim dt1 As DataTable = GetData(query1)
        For Q As Integer = 0 To dt1.Rows.Count - 1
            'For Q As Integer = 0 To 1
            check1 = dt1.Rows(Q)(0).ToString()

            Dim query As String = String.Format("SELECT Z.MacID, Z.EventName, ISNULL(DIFF,0) AS DIFF FROM (select distinct MacID, EventName from dbo.tblMachine a  join (SELECT DISTINCT EVENTNAME FROM

Open in new window

ASP.Net Web Forms app (VB.Net code behind).   Novice/beginner in ASP

I am trying to set a heading at the top of my one page that will fill the width of the page.  Want it to look like this:
MY TITLE  (label)                                                                    Company slogan =  (image file)
logo = (image file)
The slogan and logo are not text, they are image files.   I will need to be able to size the space they occupy to make them the appropriate size.

I'd like the Solgan centered from the top to bottom.

I was hoping I could use an ASP.net Table control to align this.

Here is what I have, but not sure where to go from here:
<asp:Table ID="tblHeaderTitle" runat="server" BackColor="#76B54B" Height="80px" Width="100%">
             <asp:TableRow runat="server" Width="50%">
                 <asp:TableCell runat="server"></asp:TableCell>
                 <asp:TableCell runat="server"></asp:TableCell>
             <asp:TableRow runat="server">


Open in new window

Any advice how to do this?

Hi all.

We have Visual Studio 2013 and I'm trying to load the results of a query into a multiline textbox, with the newest record on top and then each record after under it separated by ============

I have attached a sample of what I want it to look like.

It's basically pulling all the service ticket history of an account and letting our customer service reps be able to read all the history in one multiline textbox where they can scroll up and down. They say it's easier for them to read than viewing the records in a datagridview control.

My code below doesn't show any records just the ========================
Any help is appreciated.

        Dim con As New SqlConnection
        Dim cmd As New SqlCommand

        con.ConnectionString = "Data Source=myServer;Initial Catalog=myDB;Integrated Security=True"


        cmd.Connection = con

        cmd.CommandText = "SELECT Subject, Notes, CreateDate, CreateUser FROM CRMServiceTicket WHERE AccountID = @AccountID ORDER BY CreateDate DESC"
        cmd.Parameters.AddWithValue("@AccountID", accountID)

        Dim sqlReader As SqlDataReader = cmd.ExecuteReader()

 While sqlReader.Read()
 txtServiceTicketReadHistory.Text = "Subject: " & sqlReader("Subject")
            txtServiceTicketReadHistory.Text = txtServiceTicketReadHistory.Text & vbNewLine & vbNewLine & "Date/Time:" & sqlReader("CreateDate")
            txtServiceTicketReadHistory.Text = 

Open in new window

Exploring ASP.NET Core: Fundamentals
LVL 12
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

I am migrating vb6 project to vb.net. there are variant type arrays that I migrated as object types.
having this code line I get the error: Operator '=' is not defined for type 'DBNull' and type 'Integer'
                    If arrY(13, X) = gloT And (CBool(arrY(18, X)) = True Or (CBool(arrY(18, X)) = False And arr(65, X) = 100)) Then  
arr(65, X) has a null value . If I cannt initialize it to 0 how can I avoid the exception?
Is it possible to run some VB.NET code from within MSAccess!   MSaccess is my main frontend and I have
a VB.net module I'd need to run!  This is a service to access a webservice and I suppose I could write equivalent code in VBA
but was hoping to start adding VB.net code gradually to later convert everything to VB.net!  I've never use VB.net
but want to start learning it  piece by piece!

This is a snippet of code to give you an idea!  I ask because there are visual studio .NET libraries available so I assume I can!

Dim manualWebClient As New System.Net.WebClient
            manualWebClient.Headers.Add("Content-Type", "application/soap+xml;  charset=utf-8")
            Dim bytArguments As Byte() = System.Text.Encoding.ASCII.GetBytes(
                "<soap12:Envelope xmlns:xsi='http: //www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap12='http://www.w3.org/2003/05/soap-envelope'>

Just looking for a few good suggestions to point me in the right direction!

I need regular expression for following in Sql Server ( I hope it is same in vb.net or c#)
I am looking for a pattern  someletters somenumbers  some letters- someletters somenumbers  some letters     ( All capital letters)
  examples  AA111WW-B123SS

   Another pattern I am looing is   somenumbers someletters somenumbers -someletters
     examples   11AAA123-SDFG

I have this webrequest looking like this:

 Public Sub SendFile(ByVal filename As String)
            coRequest = CType(WebRequest.Create(sURL), HttpWebRequest)
            coRequest.ProtocolVersion = TransferHttpVersion
            coRequest.Method = "POST"
            coRequest.ContentType = "multipart/form-data; boundary=" & BeginBoundary
            coRequest.Headers.Add("Cache-Control", "no-cache")
            coRequest.KeepAlive = True
            Dim strFields As String = GetFormfields()
            Dim strFileHdr As String = GetFileheader(filename)
            Dim strFileTlr As String = GetFiletrailer()
            Dim info As FileInfo = New FileInfo(filename)
            coRequest.ContentLength = strFields.Length + strFileHdr.Length + strFileTlr.Length + info.Length
            Dim io As System.IO.Stream
            io = GetStream()
            WriteString(io, strFields)
            WriteString(io, strFileHdr)
            Me.WriteFile(io, filename)
            WriteString(io, strFileTlr)
            coRequest = Nothing
        End Sub

Open in new window

The GetResponse sub looks like this:
Public Overridable Sub GetResponse()
            If coFileStream Is Nothing Then
                Dim stream As Stream
                Dim response As WebResponse

                    response = coRequest.GetResponse()
                Catch web As WebException
                    response = web.Response
                End Try

                If response IsNot Nothing Then
                    stream = response.GetResponseStream()
                    Dim sr As StreamReader = New StreamReader(stream)
                    Dim str As String
                    ResponseText.Length = 0

                    For Each str In sr.ReadLine

                    Throw New Exception("MultipartForm: Error retrieving server response")
                End If
            End If
        End Sub

Open in new window

The coRequest.ContentLength is 100507 and everything seems ok, but I get this error:
you must write contentlength bytes to the request stream before calling begin getresponse

Open in new window

I do the exact same in C#:

Open in new window

Hello Experts.

I'm afraid this question might be a little vague, but I'm almost certain that it is possible to do.

Basically, I want to build a LINQ query in my vb.net project that compares two object's key fields and reports back which ones in Object A are NOT in Object B, and vice versa.

More specifically, I have a non-databound DataGridView which contains a current list of member ID's (Object A). I also have a bound DataGridView that contains an older dataset (say for example last week's member ID's).

To be perfectly honest, every time I read about SQL joins, my mind turns into a pretzel, but I feel that it's time I overcome this mental block and try to get a handle on the difference between and inner-join and an outer-join.

So, if anyone has a good example of a LINQ query that might be close to what I've described above, I would be interested in seeing what that looks like.

Always Learning,
Tony G.
Hi experts, need some help please

I am migrating a desktop app from vb6 to vb.net using vs2015.
when populating a listview I get the error "Cannot add or insert the item more than one place. You must first remove it from its current location or clon vs2015"
the vb6 code is:
Set myNode = TreeView1.Nodes("a" & CStr(x))
Set myNode.Parent = TreeView1.Nodes("a" & CStr(y))
since in vb.net I cannt set parent - the vb.net code:
myNode = TreeView1.Nodes.Item("a" & CStr(x)
 TreeView1.Nodes.Item("a" & CStr(y)).Nodes.Add(myNode)
I have these 2 functions "Add" is a test which works to add the data to the database. It works as expected but "Create" does not. Could anyone help me to figure out why.


    Public Function Add(ByVal itemToAdd As TObject) As TObject
        Dim addedItem As TObject = DbSet.Add(itemToAdd)
        Return addedItem
    End Function

    Public Overridable Function Create(t As TObject) As TObject Implements IRepository(Of TObject).Create
        Dim newEntry As TObject = DbSet.Add(t)
        dbContext.Entry(t).State = EntityState.Added
        If Not shareContext Then dbContext.SaveChanges()
        Return newEntry
    End Function

Open in new window

the data received from the machine is as under and need to build the graph from the data received as under:-

"OBX|32|ED|15000^WBC Histogram. Binary^99MRC||^Application^Octer-stream^Base64^AAAAAAAAAAAAAAABAgQHDRcmO1Z3nMPg9P/98+HKsZl8aFdGMyUfHBwcHR8iJy02QUpLTU5PT09PTUxKSEZEQkBAPz4+PT09Pj49PDo5ODg3Nzg6PD5AQ0ZISUpMTU9RU1VWWFlZWlpaWlpaWlpbW1tbW1tcXV5fYGBhYWBgXl1bWVdVU1JQT01MSkhGREJAPj07OTg2NDMxLy0sKignJSQi"

"OBX|36|NM|15057^RBC Histogram. Total^99MRC||43822||||||F


"OBX|42|ED|15100^PLT Histogram. Binary^99MRC||^Application^Octer-stream^Base64^HR0MHQwMFB0VDAsMDxQiHRoVEAwLCwsMDg8QFBoiLB0cGhcVEhAODAsLCwsLCwwMDQ4ODw8QEhQXGh4iJywzHRwcGxoZFxYVFBIREA8ODQwMCwsLCwsLCwsLCwsLDAwMDA0NDg4ODw8PDxAQERITFBYXGRocHiAiJCcpLDAzOB0=||||||F

would really be thankful if you could help to create a graph from above sequence.
These two lines of vb6 code I am trying to translate to C#:

mskFromDate.Text = Format(Date - TimeSerial((iNumDaysBefore * 24), 0, 0), "Short Date")
    mskToDate.Text = Format(Date + TimeSerial((iNumDaysAfter * 24), 0, 0), "Short Date")

I have this so far. I know it is not right.

var dt = string.Empty;
                dt = Convert.ToString(DateTime.Now.ToOADate() - (NumDaysBefore * 24));
                this.dtFromDate.Text = Convert.ToDateTime(dt).ToShortDateString();

Anybody have thoughts? I can't believe in vb6 they let folks subtract dates and numbers.
Introduction to R
LVL 12
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

I have a Web Forms application using VB

So i have a Page called TestPage.aspx and the code behind page is TestPage.aspx.vb

In TestPage.aspx.vb  on the page load event, i have a string variable which contains this value:

Dim TestVariable1 As String "This is a test string <br /> this is a test"

How do I create second variable called TestVariable2 that gets the value from TestVariable1 and if there is a < in the string replace it with a space after it.

So then the value stored in TestVariable2 would be: "This is a test string < br /> this is a test"
Hi Guys,
I am using asp.net mvc application with VB.net and I am trying to zip files and stream them back to the user to download.

Here is what I am doing
   Public Function DownloadFiles(attachmentsSelected As String) As ActionResult
        Dim obj As FileDownloads = New FileDownloads()
        ''get file list of files to download
        Dim filesCol = obj.GetFile(attachmentsSelected).ToList()

        Using memoryStream = New MemoryStream()
            Using ziparchive = New ZipArchive(memoryStream, ZipArchiveMode.Create, True)

                For i As Integer = 0 To filesCol.Count - 1
       //get the error here   ziparchive.CreateEntryFromFile(filesCol(i).FilePath + "\" + filesCol(i).FileName, filesCol(i).FileName, CompressionLevel.Optimal)
            End Using

            Return File(memoryStream.ToArray(), "application/zip", "Attachments.zip")
        End Using

    End Function

Open in new window

The issue with this code is when I am trying to download large file ...let's say 500mb I get an exception.

"Exception of type 'System.OutOfMemoryException' was thrown."

Any idea how can I fix this issue.

Thank you.
Using VB.NET 2016, After I write out a .csv file with values, how can I then format said .csv , to set a particular column to use a 2 place number format?

This is as close as I've come..and nothing happens to the worksheet afterward.

        Dim xlApp As New Microsoft.Office.Interop.Excel.Application
        Dim xlWorkBook As Microsoft.Office.Interop.Excel.Workbook
        Dim xlWorkSheet As Microsoft.Office.Interop.Excel.Worksheet
        'Dim xlSourceRange, xlDestRange As Microsoft.Office.Interop.Excel.Range
        xlWorkBook = xlApp.Workbooks.Open("MY_EXCEL_FILE ".csv")
        'Set the source worksheet
        xlWorkSheet = xlWorkBook.ActiveSheet
        xlWorkSheet.Columns.Cells.NumberFormat = "#,##0.00"

Open in new window

Hi. I am trying to remove characters from the right side of a cell in excel using vb.net so that I will be left with a date value. Here is the cell value:

Here is the code:

        'set up initial column
        strColumn = "J"
        'set up initial row
        intRowID = 2
        'Set up range
        strRange = strColumn & intRowID
        strStringDate = ForcastWorkSheet.Cells.Range(strRange).Value
        strDate = strStringDate.TrimStart(strStringDate.Length, -12)

Open in new window

The error message is "Integer values cannot be converted to Char"

Thank you in advance for any help with this.

Hi. I am trying to change the font, the font size and color of a cell in an excel worksheet from my vb.net application.

The first two lines of code run without errors but do not change anything in the cells. The third line, to change the color, gives me the following error at runtime: "System.Runtime.InteropServices.COMException: 'Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))'"

The workbook is open to not read-only and is editable, in fact, the same cells will add values.

Here is my code:

'Format formula cell to match font and size of existing cells
                ForcastWorkSheet.Cells.Range(strRange).Font.Name = "Arial"
                ForcastWorkSheet.Cells.Range(strRange).Font.Size = "9"
                ForcastWorkSheet.Cells.Range(strRange).Interior.Color = "Orange, Accent 2, Lighter 60%"

Open in new window

Hi. I am trying to show a message box when the user has chosen a file that already exists and then exit the sub. I am getting a red line under the word 'show'. The error says "Overload failed because no accessable 'Show' accepts this number of arguments."

The following is my code:

'Use filename chosen by user
        strFileName = lblChosenFile.Text

        strNewFileName = ForcastFileName(strFileName)
        If System.IO.File.Exists(strNewFileName) Then
            'The forcasted file exists
            MessageBox.Show = ("File has already been forcasted.", "File Forcasted", MessageBoxButtons.OK)
            Exit Sub
        End If

Open in new window

Can someone please help with this, it seems like it should be a simple thing to do and I have tried numerous variations ... what and I doing wrong?


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,