Visual Basic.NET

92K

Solutions

24K

Contributors

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 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
            Try
                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)
                    Next
                End Using
                Return True
            Catch ex As Exception
                MsgBox(ex.Message)
                Return False
            End Try
            

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 4
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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"
  StackTrace:
       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

0
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#.
0
I have a vb.net forms application that onload does a check against a db for information.  If the information matches the application opens the main form.  If the information does not match i need it to close the main form and open a new form.

It works if the information matches, but closes the entire app if the information does not.

Her is the code in form1_load - it pulls system info creates a hash and then calls CompareHash
        Dim strHostname As String = Environment.MachineName
        Dim strMacAddress As String = getMacAddress()
        Dim strToBeHashed As String = (strHostname & strMacAddress)
        Dim strhash As String = CreateHash(strToBeHashed)       
        CompareHash(strhash)

Open in new window


Here is the compare hash code - it pulls from sql a single value if it exists.(previously stored hash) - if it returns nothing then count is 0 for the array and it should do the close and open of forms but everything closes... Any help would be great.. thank you

 Private Sub CompareHash(ByVal strHash As String)
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("sqlConString").ConnectionString
        Dim connection As New SqlConnection(connectionString)
        Dim valuesList As New ArrayList()
        Try
            Dim command As New SqlCommand("select Hash from hash where hash = '" & strHash & "'", connection)
            connection.Open()
            Dim dataReader As SqlDataReader = command.ExecuteReader()
        

Open in new window

0
Hi All,

i want to achieve above feature.

How could I do it ?

Thank you,
0
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">
                <Grid.RowDefinitions>
                    <RowDefinition Height="220"/>
                </Grid.RowDefinitions>

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

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

                            </Style.Triggers>

                            </Style>

                        </Border.Style>

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

Open in new window

0
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.
Possible-solutions.pdf
0
Is there a way to write a script that will add a SQl database to another machine automatically without a hard wired connection string.  I have a vb.net program that has a SQL Server database that will be installed via download to 10 different independent computers in 10 different homes with 10 different users.  They will have different machines with different windows versions  etc.... They will also have different info on  each database with no connection to each other.

I would like to keep the database independent so that if i update the UI they can download it and run the install(setup) and find the database.  

I know this can be done with a local DB but then i would not be able to do UI updates.
Can someone steer me with this.
0
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
0
In vb.net how can I move an application (the vb.net app itself) over to another monitor if its there?
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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
        MasterTimer.Start()
        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
            MasterTimer.Stop()
            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?
0
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?
0
Hi,
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.
Thanks..
0
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.
0
Hi

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
0
Hello. I have a form.  On that form, I have some radiobutton lists.  On some of those list for example, if you choose no then a text box will display asking why you chose no.  But for some reason when you move to the next question and make another choice and another text box appears the previous one disappears.  I'm assuming it is because I have  autopostback=true on the lists. But if I take that out, nothing happens on the OnSelectedIndexChaged attribute of the list.   Here is the code:

Here is the radiobuttonlist where you can see where I call the function to make the panel visible and the autopostback is set to true. And I also have a validator on it to make the user choose something:
"<asp:RadioButtonList ID="rblConcernsAbtBehavior" runat="server" OnSelectedIndexChanged="rblConcernsAbtBehavior_SelectedIndexChanged" AutoPostBack="true">
                       <asp:ListItem>Yes</asp:ListItem>
                       <asp:ListItem>No</asp:ListItem>
                   </asp:RadioButtonList>
                    <asp:RequiredFieldValidator ID="concernsAbtBehaviorValidator" runat="server"
                                           ErrorMessage="Please choose one" Display="Dynamic"
                                           ControlToValidate="rblSeekingTreatmentAnotherDisability"></asp:RequiredFieldValidator>


Then I create panels for the textboxes that appear based on your choice.  Here is the panel
" <asp:Panel ID="pnlConcernsAbtBehavior" runat="server">
      …
0
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
        Me.PrintServerBox.Items.Add("PrintServer1")
        Me.PrintServerBox.Items.Add("PrintServer2")
        Me.PrintServerBox.Items.Add("PrintServer3")
        Me.PrintServerBox.Items.Add("PrintServer4")
        Me.PrintServerBox.Items.Add("PrintServer5")
        Me.PrintServerBox.Items.Add("PrintServer6")
    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.
0
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.

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

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
0
I have a datagridview, where I want to update a cell with current date based upon if a cell has a checkmark box.
0
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.

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
        Next

    End Sub
End Class



got this code and its showing the same output values as i initialized.
0
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.
Form-Inside-A-Panel-of-A-Form.PNG
0
I have a class that handles impersonation for the application.  It works fine if you use a domain account, but I cant seem to get it to work for a local account.  Some of the servers i need to run it against will not be a member of the domain.
Any help would be great
here is starting impersonation
Dim aa as New Impersonation(Username, Password)
If aa BeginImpersonation() Then
  // do stuff
End if

Open in new window


Here is the class
Imports System.Security.Principal
Imports System.Runtime.InteropServices

Public Class Impersonation

    Private _username, _password, _domainname As String

    Private _tokenHandle As New IntPtr(0)
    Private _dupeTokenHandle As New IntPtr(0)
    Private _impersonatedUser As System.Security.Principal.WindowsImpersonationContext


    Public Sub New(ByVal username As String, ByVal password As String)
        Dim nameparts() As String = username.Split("\")
        If nameparts.Length > 1 Then
            _domainname = nameparts(0)
            _username = nameparts(1)
        Else
            _username = username
        End If
        _password = password
    End Sub

    Public Sub New(ByVal username As String, ByVal password As String, ByVal domainname As String)
        _username = username
        _password = password
        _domainname = domainname
    End Sub


    Public Function BeginImpersonation() As Boolean
        Const LOGON32_PROVIDER_DEFAULT As Integer = 0
        Const LOGON32_LOGON_INTERACTIVE As Integer = 2
        

Open in new window

0
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.
0
I'm new in programming by VB.net ,But actually i've windows App. that i've created it four months ago and now i almost completed and finished it .
How can i improve my application performance .?
When i searched in the web i found an expression called "Threading" but i didn't understand it .
Any suggestions to solve my issue or to guide me to the right way
thanks in advance
0
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:
González@González.com

or other special characters.

thanks!
0

Visual Basic.NET

92K

Solutions

24K

Contributors

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,