Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


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 am trying to create a program that  loads computernames in the treeview control limited to one OU IN vb.net
I can load a combobox like this
 Public Sub ADComputers()
        Dim dirEntry As DirectoryEntry = New DirectoryEntry()
        ' NOTE: This path should be comma delimited, not semi-colon delimited
        ' Each label in the domain name should be a separate Domain Component (DC)
        dirEntry.Path = "LDAP://OU=XXX,OU=Computer Accounts,DC=XXX,DC=XXX,DC=XXX,DC=org"

        Dim mySearcher As DirectorySearcher = New DirectorySearcher(dirEntry)
        ' This value can be passed in the constructor if preferred.
        mySearcher.Filter = "(objectClass=Computer)"
        mySearcher.PageSize = 1001

        For Each resEnt As SearchResult In mySearcher.FindAll()
            ' List box is a bit simple for these unless I missed something
            ' lbADUsers.Items.Add(resEnt.Properties("sAMAccountName")(0).ToString())
            ' lbADUsers.Items.Add(resEnt.Properties("aDSPath")(0).ToString())
            ' And this one needs some work unless you're attaching to every object within the directory.
            ' lbADUsers.Items.Add(resEnt.Properties("objectGUID")(0).ToString())
        txtComputerCount.Text = TSCmbADC.Items.Count
    End Sub

Open in new window

Concerto's Cloud Advisory Services
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

I would like to call the sub on my page.aspx.vb page using the existing JavaScript function

Public Sub doDataCall()
   ' Do sub code here
End Sub

Here is my page html button
I cannot switch to .net button
There is a LOT of css applied to the button and any change I attempt to make leads to a disaster elsewhere

            <button onclick="doFunction();">Pay <asp:Label ID="lblAmount" runat="server"></asp:Label></button>

JavaScript current function
I need to pass in foo to the vb sub

    <script type="text/javascript">
        function doFunction() {
            var uri = window.location.href;
            var lastslashindex = uri.lastIndexOf('/');
            var result = uri.substring(lastslashindex + 1);

Open in new window

I have a windows forms application that uses impersonation to check, start and stop service.  that works perfectly. Impersonation is doing its job.
in case a service will not stop I want to kill the process.  I am using the same impersonation, but for some reason I get access is denied with i try and kill the process.. any help would wonderful

Private Function KillProcess(ByVal strPC As String, ByVal strProcess As String)
        Dim Username As String = txtUserName.Text
        Dim Password As String = txtPassword.Text
        Dim domain As String = "."
        Dim localimersonate As New LocalImpersonate
        MsgBox("Attempting to Kill the " & strProcess & " Service")
        If localimersonate.impersonateUser(Username, "", Password, "local") Then
                Dim scope As New ManagementScope("\\" & strPC & "\root\cimv2")
                Dim query As New SelectQuery("SELECT * FROM Win32_Process WHERE Name = '" & strProcess & "'")
                Using searcher As New ManagementObjectSearcher(scope, query)
                    Dim queryCollection As ManagementObjectCollection = searcher.[Get]()
                    For Each process As ManagementObject In queryCollection
                        process.InvokeMethod("Terminate", Nothing)
                End Using
                Return True
            Catch ex As Exception
                Return False
            End Try

Open in new window

I am receiving the below error.
System.InvalidOperationException was unhandled
  Message="An error occurred creating the form. See Exception.InnerException for details.  The error is: The type initializer for 'MyProject.Singleton' threw an exception."
  Source="Prj - MyProject"
       at MyProject.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
       at MyProject.My.MyProject.MyForms.get_F_Login()
       at MyProject.My.MyApplication.OnCreateMainForm() in C:\Users\xxxxxxxx\Documents\Source_MyProject\Prj-MyProject\Prj\My Project\Application.Designer.vb:line 35
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
       at MyProject.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.TypeInitializationException
       Message="The type initializer for 'MyProject.Singleton' 

Open in new window

Hey all,

I have an application that is being used for many clients. However, I've been asked to consolidate to a single code base. The application is also in need of a nice face lift to become more aesthetically pleasing as well as to increase the over all UI/UX. I've never event attempted something like this before so my question is: Would it best to develop/re-develop in C#/MVC or WebForms or modify the current VB.NET application to utilize new features etc.? All of the clients have a similar type of service, however, there are some drastic differences to features, the display of information etc. That being said, I'm not too sure of how cost effective it would be to attempt to consolidate into a single code base vs redeveloping the application utilizing as much code as possible with translation into C#.
Hi All,

i want to achieve above feature.

How could I do it ?

Thank you,
Hi, I ve been playing with this for a while and I can't make it work. Basically, I have a listbox with an image and a label. What I'd like is to change the color of the border of the image if that item is selected (the listbox is set to multiple selection)

This is I have so far...

 <DataTemplate x:Key="ListBox_DataTemplate">
            <Grid HorizontalAlignment="Center">
                    <RowDefinition Height="220"/>

                 <Border x:Name="thumbBorder"  BorderThickness="8"  CornerRadius="8">
                        <Style TargetType="Border">

                                    <DataTrigger Binding="{Binding isSelected, ElementName=lb_images}" Value="True">
                                    <Setter Property="BorderBrush" Value="SteelBlue"/>
                                <DataTrigger Binding="{Binding isSelected, ElementName=lb_images}" Value="False">
                                    <Setter Property="BorderBrush" Value="Yellow"/>




                    <Image Width="170" Height="190" Source="{Binding Thumbnail}" 

Open in new window

This happened before but only randomly - now it's happening all the time on all the machines for a client of mine. They connect to the UPS website to download/import shipment tracking information. The application (Microsoft Access) calls an external .exe written in VB.net and it does its thing. Been working fine for years...

Now we get the above message in more than 75% of the instances when the program in invoked. Mind you, that if the user clicks the button again (and again) it will eventually connect and provide a tracking number and disconnect from the UPS site as designed.

I'm working my way through the suggested fixes (I Googled) but wanted to know if any of you experts experienced this and could give me some direction.
I wrote a parser that reads from several files to produce a consolidated file.
This works fine when invoked interactively either from the command line or from file manager.
When I run this from Task Scheduler, the program starts, and writes the header to the target file, but nothing from there.
When run interactively, all of the data populate.

VB.Net  written using VS 2017
Running on Windows Server 2012
In vb.net how can I move an application (the vb.net app itself) over to another monitor if its there?
Tech or Treat!
LVL 10
Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

I have added a ProgressBar and Timer to my project but it's behaving strangely. When I press a button it just increments the progress bar by 1 until it finishes regardless of how long the buttonclick event took. I would like to have it increment and fill to 100 when the event finishes.

Here is my code for the bar under my buttonclick event:

Private Sub FixAllButton_Click(ByVal sender As System.Object, e As EventArgs) Handles FixAllButton.Click
        MasterProgressBar.Value = 0
        FixAllButton.Enabled = False

Open in new window

Here is the rest of the code in the timer sub:

Private Sub MasterTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MasterTimer.Tick
        MasterProgressBar.Value += 1
        If MasterProgressBar.Value = 100 Then
            FixAllButton.Enabled = True
        End If
    End Sub

Open in new window

How do I make the progress bar dynamically increase depending on the length of time it takes to complete the event and then fill when it ends?
Is there a way to make sure that when I call the Excel and Workbook open commands inside my vb app that I can always make sure they open at the top most of all forms and not behind a form?
I am working with vb.net project.
I have successfully done single authorization and single capture,
but I can not find multiple capture code.
Where is multiple capture code please know me.
I can not find equivalent vb code of c# for specific section of paypal payment.
I am working with paypal billing plan and agreement.
Redirect code in c# is
this.flow.RecordRedirectUrl("Redirect to PayPal to approve billing agreement...", link.href);

Open in new window

but can not find its equivalent in vb.net.
Please help asap.

I am looking for a VB script that would allow to type full name or users name in a search box that would run against certain LDAP groups (43 groups) to confirm if the user exists. If the user exists the output should be display on the screen and save in CSV file.

These 43 groups exists in AD (LDAP).

Thank you, M
I'm writing a program that will install a network printer depending on selections made in two combo boxes.

Here is my form:

printer app form
Here is what I have so far for code:

Public Class AddPrinterForm

    Private Sub AddPrinterForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub

End Class

Open in new window

I have a spreadsheet that has 1 sheet populated with columns A-F with the names of the printers.

I would like the 2nd ComboBox (PrinterNameBox) to be filled with content from whichever PrintServer is selected in ComboBox1 (PrintServerBox) relative to the columns in the spreadsheet. PrintServer 1 = Column A, 2 = Column B and so forth. Then people will click Install Printer! and the button will execute a command depending on the variables selected in the ComboBoxes.

I've looked everywhere and I cannot find how to do this. Every place I find has solutions for SQL Server but not a simple spreadsheet or other solution.

If this is not the place to ask newbie questions like this please let me know a good place to go.
I inherited a form that has an html button it
I need to build a on click event (Server side) that redirects to another page

Right now I have a .net label inside the button that works... but it does not make the entire "button" click area.

                <asp:Label ID="lblPayNow" CssClass="lblbutton" runat="server" Width="100%" Height="100px"></asp:Label>

Server side (.Net)

Page load
Dim path As String = HttpContext.Current.Request.Url.AbsoluteUri
path = path.Replace("TextLanding", "Payment")
lblPayNow.Text = "<a href='" + path + "' style='text-decoration:none;color:#ffffff; width:100%;'>Pay Now</a>"

All of this works...
I just need the "Pay Now" link to fill the button
I have a datagridview, where I want to update a cell with current date based upon if a cell has a checkmark box.
Public Class Form1
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim array(6) As Integer
        array(0) = 7
        array(1) = 2
        array(2) = 4
        array(3) = 1
        array(4) = 5
        array(5) = 3

        Dim value As Integer
        Dim i As Integer
        Dim n As Integer

        For j = 1 To n - 1
            value = array(j)
            i = j - 1

            While (i > 0 And array(i) > value)
                array(i + 1) = array(i)
                i = i - 1
                array(i + 1) = value

            End While

        Next j
        Dim stOut As String
        For i = 0 To 6
            stOut = ListBox1.Items.Add(array(i)) & vbNewLine

    End Sub
End Class

got this code and its showing the same output values as i initialized.
Free Tool: Site Down Detector
LVL 10
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Hi All,

I try show a form inside a panel of form.
The problem is the form is not resized based on panel size.

Please see the attached file.

What's the problem ?

Thank you.
I have done other projects with a detached cloud based sql server database.  This one i need a self contained disributable program over many machines with it's own attached database.  Can some one steer me as to the best direction for an installer(short of spending gobs for installshield) that would install the all the prerequiste files.  These machines may or may not have SQL .  Is there a script to auto download SQL Express and adjust the connection string to there computer.  I am a single developer, doing what i do in visual studio community and sql express.  Would SQL lite work? MySQl?  no experience there.  
This is a very small database with no more than 10,000 records.  I have INNO Setup that i have used but i don't think it handles this.  it does handle visual studio however.
Thanks much.
asp.net vb.net
I want to validate an email that uses accents, but with the validation that I have, I get a validation error:

.ValidationExpression = "^[\w\.\-\']+@[a-zA-Z0-9\-]+(\.[a-zA-Z0-9\-]{1,})*(\.[a-zA-Z]{2,3}){1,2}$"

How do I add all possible characters to this:

or other special characters.

Hi, if anyone knows about smartcloud, SCAPM technology, please help me
Hi Experts,

This is my code to display the save message while exiting the form without saving. I know how to not show it when 'Save' button is clicked. But how can I stop it from popping up while any option button is clicked which has a postback.

Thanks in advance.

Option button code
<asp:RadioButton ID="rbMenuItems" runat="server" Text="Menu Items" class="RadioButtons" GroupName="grpRbMenu" AutoPostBack ="true"/>

<script src="js/jquery.min.js"></script>
        var NoDirtyScreen = false;
        var Changes = false;
        function DirtyScreenHide() {
            NoDirtyScreen = true;

        $(document).ready(function () {
            $("input[type='text']").change(function () {
                Changes = true;

            $("select").on("click", function () {
                Changes = true;
        var unloadEvent = function (e) {
            if (!NoDirtyScreen && Changes) {
                var confirmationMessage = "Warning: Leaving this page will result in any unsaved data being lost. Are you sure you wish to continue?";

                (e || window.event).returnValue = confirmationMessage; //Gecko + IE
                return confirmationMessage; //Webkit, Safari, Chrome etc.
       window.addEventListener("beforeunload", unloadEvent);
I have a unbound datagridview.  If the user leaves the grid to enter another control when they return to the datagridview the current row will not accept edits.  The user can enter a new value in a cell on the row but as soon as they leave the cell the value returns to the value the cell was set at when the grid lost focus.

The current workaround is that If the user selects another row and then returns to the original row they can edit the row normally.

Any ideas?


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,