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 would like to create an application using VB.NET Visual Studio 2017 using the VideoLan VLC ActiveX plugin but need to specify the audio output device like I can in the actual VLC application. Can I do this using the ActiveX?

This is because I will have 3 TVs connected to 3 different HDMI ports on the same computer and need different sound and images on each of them. Putting different screen image on each monitor is done, but not the sound.

Or, if I have 3 different graphics cards and use the HDMI ports on each individual card would I be able to output sound to the individual TV's?
Ready to get started with anonymous questions?
Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

 I want to upload my excel data file to access using button event. Below is my code.

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

        Dim Conn As OleDbConnection

        Dim Cmd As OleDbCommand

        Dim Filename As String = "D:\Ayyappan\claimDump.xlsx"



        Dim StrFileName As String = String.Empty

        Dim XLA As New OleDbDataAdapter

        Dim XLTable As New DataTable

        Dim StrSelect = "SELECT * FROM [{0}]"


        OpenFileDialog1.FileName = ""

        OpenFileDialog1.Filter = "Excel |*.xlsx|All files (*.*)|*.*"

        If OpenFileDialog1.ShowDialog() <> Windows.Forms.DialogResult.OK Then

            Exit Sub

        End If

        StrFileName = OpenFileDialog1.FileName

        Conn = DBConn()


        Cmd = New OleDbCommand("INSERT INTO claimDump([a],[b],[c],[d],[e],[f])  SELECT * INTO [Excel 12.0 xml;DATABASE=" & StrFileName & ";Extended Properties=Excel 8.0;]", Conn)


        ' Catch ex As Exception

        ' MsgBox("Some error")


        'End Try


    End Sub

While running the code I got "IErrorInfo.GetDescription failed with E_FAIL(0x80004005" this error.

Am checking my excel sheet the header name is same as per the insert statement like a,b ,c etc..

Can anyone help me on that.

I have to insert a row in MS SQL when my application starts and update the same row when the application closes.

I'm know where to put the code, but how do I update the same row? (i have no uniq identifiers)

Thanks in advance

I have a subdomain subdomain1 in a primary domain
I created a folder myfolder under the subdomain root, and granted public read/write access on

When I write the following code In my windows application,
            Dim upload As New System.Net.WebClient()
            upload.UploadFile("" , mylocalfilefullpath)

I am getting error 404 (non existing folder or file. What Am I doing wrong. Thanks for the help

  I am created a one application for my project. The Application's exe file has been copied to another machine. i want to run the application manually whenever i run the macro. in that Application have 1 text box and 1 combobox. now i have list of values in excel . how can i pass the value in that application. please help me on that.
I would like in my Visual Studio or c# project a way to link to code methods that it impacts. Is this possible in Sandcastle?
I am having a situation where I am using the HtmlPushpin and everything is working create UNTIL I need to do a code-behind call. 

When that is done and it returns the HtmlPushpin object does not exist. 

What options do I have a that point? AJAX? But I need to keep the object on the JavaScript. Much like the Microsoft.Maps.Map object persists.

I am initially registering the module when the map is loaded with the key with the:
Microsoft.Maps.registerModule('HtmlPushpinLayerModule', '../js/HtmlPushpinLayerModule.js');

And when I have another code behind process execute and it returns back it's trying to use the HtmlPushPin object. It's obviously no longer present and I get an "HtmlPushpin is undefined" message. 

Are there any options...can I load the module from the code-behind? 

Any information would be greatly appreciated!
When a user attempts to launch a program, I would like to check to see if anyone else I already running the program and, if so, display an error message and abort the launch.  I assume this would be done in the Load event.  How can I do this using code?
I have runtime text boxes that are created during the page load event. I would like to be able to re-align text boxes based on the a selected text box or possibly right click and a context command.

how can I do this?
I want to copy some data in row or column in crystal report when viewing and pass it data to MS Excel and keep the right format as when view in crystal report like that:

Crystal report data (I selected login Time column data and press Ctrl + C to copy)
and i want to paste that selected data into excel like that:
Is this possible?
Thanks in advance for help.
Salesforce Has Never Been Easier
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 Dim path_original As String = "C:\Booking Number\Accounts\Epicor Invoices\Source\"
    Dim path_error As String = "C:\Booking Number\Accounts\Epicor Invoices\Error\"
    Dim path_success As String = "C:\Booking Number\Accounts\Epicor Invoices\Completed\"

    Dim parentId
    Dim directoryName As New DirectoryInfo(path_original)
    Dim dirFileName As IO.FileInfo() = directoryName.GetFiles()
    Dim fsize = dirFileName.Length
    If (fsize > 0) Then
        Dim dirReadFileName As IO.FileInfo
        Dim logFileName As String = String.Format("log{0}.txt", Now.ToString("MMddyyyy_hhmmss"))
        Using w As StreamWriter = File.AppendText("C:\Booking Number\Accounts\Epicor Invoices\logs\" + logFileName)
            Dim sobj As SFDC.SforceService = New SFDC.SforceService
                Dim lr As SFDC.LoginResult = sobj.login("username", "password")
                sobj.SessionHeaderValue = New SFDC.SessionHeader
                sobj.SessionHeaderValue.sessionId = lr.sessionId
                sobj.Url = lr.serverUrl
                'Dim sobject As WebReference.sObject = New WebReference.sObject
            Catch ex As Exception
            End Try
            For Each dirReadFileName In dirFileName
                    Dim attachment As SFDC.Attachment = New SFDC.Attachment
                    Dim filenames = 

Open in new window

I got this dumped in my lamp. They need a timer for their Excel vba application. I create a COM class in Visual studio, register for COM Interop, serialization is on AUTO, and XML documentation is checked. Builds fine. I build and import into Excel fine. But when it encounters the new variable it says it can't create the ActiveX component. What they want is the timer to run until it reaches a certain count and then notifys the vba code it is done and displays that value in the spreadsheet - without locking out any other activity going on. Below is the code for the dll in I don't get beyond the import reference in Excel and instantiating the object before the ActiveX error. Going nuts here any help appreciated.

 ' A creatable COM class must have a Public Sub New() 
    ' with no parameters, otherwise, the class will not be 
    ' registered in the COM registry and cannot be created 
    ' via CreateObject.
    Public tmrUpdate As New System.Timers.Timer
    Private TimeLeft As String
    Public timeUpDate As Integer

    Public Sub New()
        AddHandler tmrUpdate.Elapsed, AddressOf Tick
    End Sub
    'Public Function TestExport(left As Int32, right As Int32) As Int32
    '    Return left + right
    'End Function
    Private Async Sub DoStuff()

        'Doing stuff

        timeUpDate = 599

Open in new window

I am considering using Devexpress MVC for a simple table-based project.  A colleague says not to do it because it will increase the need for custom UI coding.  Does anyone have experience with whether using Devexpress MVC controls increased or decreases the need for custom UI coding?
Hello everyone.

I've seen that what I'm trying to do which is monitoring the file IO require the use of Window File System Filter driver and I've also looked into it but was a bit hard to understands especially as I'm not a C++ developer. What I want to achieve is to be able to trap file copy, creation, as well as file sources and destinations, lets say I'm copying a file within my computer I want to get the source path of the file as well as destination path of the file and also the file name as well and if possible with the application that is sending the file.

I saw that this can also inform you if there is file access(opening of file, reading of file) this is very much important to me to also get it if possible while the request of file open is created. I wan to trap this and if the file is one of my file then I want to first work on the requested file first (decrypt).

Thank you.
I'm writing a program to monitor all the services on a specific pc.

this is part of my code :


Dim lista As ServiceController()
lista = ServiceController.GetServices(PCNAME)

For Each s As ServiceController In lista

i got :

s.Servicename, s.displayname, s.status etc etc


What i need is the Starttype of the service. If i go in debug , i can see the "s.Starttype" to be (Automatic, Manual, Disabled)...etc tec but writing my code i got error when i write down the "s.starttype" i receive error that this "starttype" doesn't exist.

Any help ??

thanks a lot
In my .net c# project I have two jason like this


Open in new window


Open in new window

I need to compare this to json and get the result of the modified part oly

Open in new window

Thank you for your help!!
How can I add a clickable button event on a text box. I want to be able to have the end user enter information into a text box then have them double click the box and I would use a dynamic sql statement in to update the database with the info they entered in the text box.
Can anybody help me to convert this code from VB.NET to VBA. It should afterwards be running on a system with: Win10, Excel 2013, VBA

Here is the original Code in VB.NET including the improvment further down in the thread:


<DllImport("gdi32.dll")> _
Public Shared Function GetFontUnicodeRanges(ByVal hds As IntPtr, ByVal lpgs As IntPtr) As UInteger
End Function  

<DllImport("gdi32.dll")> _
Public Shared Function SelectObject(ByVal hDc As IntPtr, ByVal hObject As IntPtr) As IntPtr
End Function  

Public Structure FontRange
    Public Low As UInt16
    Public High As UInt16
End Structure  

Public Function GetUnicodeRangesForFont(ByVal font As Font) As List(Of FontRange)
    Dim g As Graphics
    Dim hdc, hFont, old, glyphSet As IntPtr
    Dim size As UInteger
    Dim fontRanges As List(Of FontRange)
    Dim count As Integer

    g = Graphics.FromHwnd(IntPtr.Zero)
    hdc = g.GetHdc()
    hFont = font.ToHfont()
    old = SelectObject(hdc, hFont)
    size = GetFontUnicodeRanges(hdc, IntPtr.Zero)
    glyphSet = Marshal.AllocHGlobal(CInt(size))
    GetFontUnicodeRanges(hdc, glyphSet)
    fontRanges = New List(Of FontRange)
    count = Marshal.ReadInt32(glyphSet, 12)

For i As Integer = 0 To count - 1
    Dim range As FontRange = New FontRange
    range.Low = Unsign(Marshal.ReadInt16(glyphSet, 16 + (i * 4)))
    range.High = range.Low + 

Open in new window

Hi Experts,
     I have PDF files which are 1) normal text based and 2)other PDFs which are just images .    Is there a way using .NET code I can find a file is type 1) or type 2)        
 While I open PDF in notepad for Text based  PDF (Type 1) I see  "Filter/FlateDecode" which I believe is not present for image based (Type2)  .   Can this header like information be used someway ?

  Your help is appreciated
Free Tool: IP Lookup
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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 have an ASP.NET product page. The product page contains drop-down menus for category and subcategory. If I need to create/alter/delete either a category or subcategory I click 1 of 2 buttons to open a separate page (either category page or subcategory page) and subsequently add/alter/delete 1 or more categories or subcategories. Upon closing or committing the add/alter/delete to the category or subcategory page I need to fire an event on the product page (which does not have focus) in order to refresh the category and sub-category drop-down menus.

Is there a way to do this please?

Much thanks,
David Bach
I am seeing double boxes on my web form grid on some fields.
It is definitely the data because If I load the data value into a label  it shows the same way.

vb.Net web forms .Net 4.5
MS SQL Server 2012 database

You can see the boxes below in ALL the email addresses and one of the last names.
How can I trim this?

We have tried LTRIM and RTRIM

And the data is coming in from a service with varname.ToString().Trim()

I am writing an application that will extract the history files and allow the user to view it in a table or DataGridView. The issue I am having is converting the timestamps when the data is displayed. There are tons of articles about it, but not of them seem to work. It is possible that my skill level is not high enough to understand them.

At the moment I dump the data into the grid view, should I convert it prior to or after?
I have the following query and in the past another record was updated. I'm trying to find out what is the best way to prevent this. I feel this is not the best way to write an update statement.

The line in question that I have is    strSQL2="UPDATE LDA_CAN_ROLE_GAP set " & DBTABLE & "='" & NewText & "' where CR_ID='" & CRGID & "'"

	<tr><td> <FONT COLOR=RED><B>Edit Fields and hit "Save" to Update Candidates <%Response.write(Caption1)%> for this Role</B></FONT></td></tr>
<form method="POST" action="EditSkillGap.asp?UID=<%=UID%>&CID=<%=CID%>&CRGID=<%=CRGID%>&RID=<%=RID%>&PCID=<%=PCID%>&EID=<%=EID%>&DBTABLE=<%=DBTABLE%>">
<table  width=560 cellpadding=4 cellspacing=1   border=1  bordercolor="LightGrey" bordercolorlight="LightGrey" bordercolordark="White" align="left">
 <INPUT TYPE="hidden" NAME="UID" VALUE="<%=UID%>">
    <%sqlqt=Chr(39) %>
<%if Request.Form("UPD")="Y" then
    NewText=Replace(NewText,sqlqt,sqlqt & sqlqt)
  [b]  strSQL2="UPDATE LDA_CAN_ROLE_GAP set " & DBTABLE & "='" & NewText & "' where CR_ID='" & CRGID & "'"[/b]
    adoRs1.Open strSQL2, strDSN

    end if %>

Open in new window

I have dynamically added linkbuttons added to the page and they disappear on postback.
The linkbuttons are recreated on postback in the page init but the values are gone.
What could be the problem?
It should be enough to create the same number of linkbuttons with the same ID, am I right?
Hey I had gotten some code  from an EE Tech but I still need Help let me show you I want to make Many Calls to WMI Namespace to retrieve and execute remote PC Functions so in form code I wrote
Public Sub RunningProcesses()
        Dim options As ConnectionOptions
        options = New ConnectionOptions
        options.Username = "XXXXXX"
        options.Password = "XXXXXXXXXXXXX"
        '* Test the connection

        '  Dim ps() As Services

        ListProcess.Columns.Add("", 100, HorizontalAlignment.Left)
        ListProcess.Columns.Add("Process ID", 120, HorizontalAlignment.Left)
        ListProcess.Columns.Add("Caption", 120, HorizontalAlignment.Left)

        ListProcess.Columns.Add("CommandLine", 400, HorizontalAlignment.Left)
        ListProcess.Columns.Add("Priority", 120, HorizontalAlignment.Left)

        ListProcess.Columns.Add("Memory", 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 Win32_Process")

        On Error Resume Next
        Dim searcher As ManagementObjectSearcher
        searcher = New ManagementObjectSearcher(scope, query)

        Dim queryCollection As ManagementObjectCollection

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,