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'm using Visual Studio Community 2017. In my case, I have text box named: txtSEARCH, Button named: cmdSEARCH and a Datagridview named: DataGridView1.

Datagridview populated from a text file named: "D:\esdcheck\.BAK.dll" and manualy put column in properties.
This is how I make columnsand this is my DataGridView (This is my form)
Sample For
What I want to do is to search User ID and display it in DataGridView

I type "1504579" in the text box (txtSEARCH) and when I click the button, datagridview will display all "1504579" in the list 'ONLY' from Rowel Virgo

I'm searching all day in the internet but no codes for like that, any help please and Thank you

This is How I populate my DatagridView:

Public Class Form1

    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Dim lines = (From line In IO.File.ReadAllLines("D:esdcheck\BAK.dll")
                     Select line.Split(CChar(","c))).ToArray
        For x As Integer = 0 To lines.GetUpperBound(0)

    End Sub

End Class

Open in new window

this is my first post Listview and Datagridview  and thank you for the reply sir
Scott McDaniel (Microsoft Access MVP - EE MVE )
Ryan Chong
Independent Software Vendors: We Want Your Opinion
Independent Software Vendors: 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!

Hi all
can i

<asp:BoundField HeaderImageUrl="~/Images/<%=Session("uno")%>.png" 

Open in new window

need a session value inthere is that posible?
I think I am still having a Session issue. I am also noticing that when I leave my web page alone for a while I will come back and I will be on my Expired Session page. But sometimes, while Im working, I notice that my page will do a postback without me doing anything.
I would LOVE to find out the following  
A.) what is causing this to postback out of nowhere
B.) if its not the Session ending how can I find out what is causing my app to postback by itself?

This is causing the app to start from ground zero, so to speak...
For instance, I have a datalist on the left of the screen and it has timesheets by weeks,  that when selected they fill a gridview and blablabla....I could be working on the 3rd timesheet in the list but when this postback happens it goes back to the first timesheet as if you were coming to the page for the first time.....Im hoping this makes sense

Bottom line is, I think Session ending is causing this to happen but it does NOT always redirect to my Session Expire screen for some reason??? Sometimes it does but other times...not so much!!

My code in all of my MAIN page loads are the following...
        'Check for Session State and if gone then redirect to Expired form
        Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) + 5))
        If Session.IsNewSession Then
            Me.Master.PageLabel = ""
        End If

Open in new window

I think I need to use this Response.AddHeader code to possibly send me a message box before Session ends and somehow extend session if the user wants to stay logged in? Has anyone ran into this before? I cant be the only one this has happened to??
Any help would really be appreciated
So, a client would like to be able to have their employees receive a message if they haven't entered in time within the last 7 days. Specifically Monday - Monday at 12:00PM. If the employees have not entered in time by noon, they should be locked down and only allowed to enter time for dates that fall within the last 7 days. The code is written in VB.NET and utilizes SQL and Stored Procedures heavily. I was hoping to get some ideas in regards to possible ways to go about this.
I am trying to find the best support for this process. I want to be able to make a call to an excel grid in any version of  Excel (2003-2016) so that I can export the setting.

What do I need in order to do this?

Thanks in advance.
I have just started to work with WPF using and have had trouble getting the DataGrid to work with the Access Database (Jet) that holds my data.  I learn best through examples and I would be grateful if someone can give me sample code (both XAML and VB) to solve the following situation.

I have a DataGrid as follows:
            <DataGrid Name="dgPayment" Margin="10,15,10,10" Grid.Column="0" AutoGenerateColumns="False"
                      IsReadOnly="False" CanUserAddRows="True" CanUserDeleteRows="True" >
                    <DataGridTextColumn Header="Seq" Binding="{Binding Path=CL_Seq}" />
                    <DataGridTextColumn Header="Name" Binding="{Binding Path=CL_Name}" Width="200" />
                    <DataGridTextColumn Header="Hdr1" Binding="{Binding Path=CL_Hdr1}" />
                    <DataGridTextColumn Header="Hdr2" Binding="{Binding Path=CL_Hdr2}" />
                    <DataGridTextColumn Header="Hdr3" Binding="{Binding Path=CL_Hdr3}" />

I have code behind as follows:
            Using conn = CashConnection

I have to generate a report in PDF from a table in SQL Server in a VB.Net app. I have defined a report (.rdlc file), but I don't know how to generate the report. I have only found a MS article on LocalReport, but the code shown in it does not work, I'm using VisualSudio 2013.

Can someone guide me through the process ? Or should I make a WinForms app instead ?

Thnaks for help
Dear experts
 how do i achive

 Dim txtemail As String
        Dim registros As Integer


        Dim sql4 As String = "select count(*) from nfl"
        Dim cmd4 As New OleDbCommand(sql4, cn)
        registros = (cmd4.ExecuteScalar())

        Do While registros >= 0
            Dim sql3 As String = "select mail from nfl"
            Dim cmd As New OleDbCommand(sql3, cn)
            txtemail = (cmd.ExecuteScalar())


            registros = registros - 1

Open in new window

but move bettween records to get the email value

Oh Dear experts,
I need to atach a file that is in my hard drive in code behind
what is the propper sintax for


In oracle have a stored procedure return a clob and in assign the clob to a devexpress richtextbox's rtftext property
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!

Hello all. I have an ASP.NET web forms application that has been working fine until a recent change from cookies to session variables (don't think that has anything to do with it but ...) and an upgrade of the Telerik controls.
The same code behind, in two separate ASPX pages (print and reprint), behave differently. They both use this format:

1 Dim PrintCmd as String = "PrintForm.aspx?var1=value&var2=value..."
2 PrintCmd =  "<script language=javascript> {'" & PrintCmd & "', '_blank');}</script>"
3 WriteNlog.Info(PrintCmd)
4 Response.Write(PrintCmd)
5 Response.Write(PrintCmd.Replace("Some Text","Other Text")
6 CallNlog.Info("Returned from print")

The page being called is a simple ASPX that copies the query values to labels and then the body performs window.print() then window.close(). It makes an NLog entry at preload and load, when it works.

Page1.aspx executes 1,2,3 and 6. Logging in the PrintForm.aspx does not occur, no error is reported, as if 4 and 5 are comments.
Page2.aspx executes 1 through 6 without fail.

Both origination forms use the same site master with Telerik controls (RadScriptManager, RadMenu, RadAjaxLoadingPanel and RadAjaxManager).
The print page is pure ASP webform.

Alternately I have tried:
4 ClientScript.RegisterStartupScript(Me.GetType(), "receipt1", PrintCmd, True)
5 ClientScript.RegisterStartupScript(Me.GetType(), "receipt2", PrintCmd.Replace("Some Text","Other Text"), True)

Again, page2 works flawlessly and …
I am trying to publish a windows form application to ftp site.
It runs for a few minutes and then I get some errors, see bellow. I know that the credentials are good as it does manage to create some folders.

Severity      Code      Description      Project      File      Line      Suppression State
Error            Failed to copy file 'D:\MyActiveData\Abe\Documents\2017\Projects\ML\MLiq\MLiq\bin\Debug\app.publish\Application Files\MLiq_1_0_0_2\HtmlAgilityPack.dll.deploy' to ' Files/MLiq_1_0_0_2/HtmlAgilityPack.dll.deploy'. Unable to add 'Application Files/MLiq_1_0_0_2/HtmlAgilityPack.dll.deploy' to the Web site.  An unknown WinINet error has occurred (code 12113).      MLiq            1      
Severity      Code      Description      Project      File      Line      Suppression State
Error            Failed to copy file 'D:\MyActiveData\Abe\Documents\2017\Projects\ML\MLiq\MLiq\bin\Debug\app.publish\MLiq.application' to ' Files/MLiq_1_0_0_2/MLiq.application'. Unable to add 'Application Files/MLiq_1_0_0_2/MLiq.application' to the Web site.  An unknown WinINet error has occurred (code 12113).      MLiq            1      
Error            Failed to copy file 'D:\MyActiveData\Abe\Documents\2017\Projects\ML\MLiq\MLiq\bin\Debug\app.publish\Application Files\MLiq_1_0_0_2\MLiq.exe.config.deploy' to ' Files/MLiq_1_0_0_2/MLiq.exe.config.deploy'. Unable to add 'Application Files/MLiq_1_0_0_2/MLiq.exe.config.deploy' to the Web site.  An unknown WinINet error has occurred (code 12113).      MLiq            1      …
I want to store HTML code in database.
is it possible? If yes then how?
I have an MS Access Database connected to the application. I want to be able to install the application on several computers. I want to give the users an option to "Compact and Repair" the database. I have included a copy of the database in my resources folder of the application.

I know I need the Microsoft.Office.Interop.Access.Dao.DBEngine, but I am unsure of where to start.

what would be the best way to do this? Should I copy the file from my resources or what?
I need to stop the user register if the username is contained in the password
this work for me


Open in new window

But i need it to stop the registration if is

Ernesto or ernesto

at this moment just if is  ernesto or ernesto  quits

i mean, how to do it no mater the  CASE!

BAD JOB Experts-Exchange!  I just uploaded a project for others to help try to figure out why I can't do something and the number of times it failed because of this file and that file and the other file is INSANE.  It's a VB.NET project - I simply compressed the directory.  But of course, I built it once... so you didn't like the .exe... then the .user file with my settings, then .suo file, then the .settings file, then the password protected .zip file, then... I practically quit and went to ask the question somewhere else!
LVL 17

Expert Comment

by:Kyle Santos
Could you email me the file type so I can try to reproduce the problem you're experiencing?
Everything was going well... playing around with Visual Studio 2017 for the first time...

Had a weird problem (#1, but not really what the question is about where even though I set the Assembly Name and Root Namespace names, ApplicationName was still returning "WindowsApp1" when referenced... so I thought maybe it's building using that temp name when run from VS IDE.  So I compiled it into an app and deployed it.  Same result...

So I try re-opening the project - I can't open forms!  I can a new form, but when I try to open the main form, the only "main" reference I have is main.vb.  And when I open that, I don't have any code either!  I have one other form in the app and I can't open that either (but the code is visible).

I'd really like to continue this project but I need to see the forms!  HELP PLEASE!?!

(Classic Windows Forms app).
Hi all, I need to start an aspx page with a modal window if a codebehind query condition is true,
how to achive that dear experts!!!
How can i highlight the cell border when clicked on it.

I am using 2015 desktop.

Industry Leaders: We Want Your Opinion!
Industry Leaders: 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 had this question after viewing search a textbox for a key word in a Listview.

I want textbox1 listview1 and button1 to search and display all same items in listview and remove other items to display only the word I search. How?

Like this one , search name Nikko and display Only nikko's record
I'm using Visual Basic in a Windows forms .net framework 4.0 application.

On load of my window I set a variable to the default value of this:

Dim TestVariable1 = "A"

I have a button called Button1 on my page.

I want to have the button toggle the value of my variable between 3 different values.

So if I click the button once then my variable is set to the following:

  TestVariable1 = "B"

If I click on the button a second time then my variable is set to the following:

  TestVariable1 = "C"

Then if I click the button a 3rd  time then my variable is set back to the following and the sequence starts over again:

  TestVariable1 = "A"

So then to summarize, on each button click , the button will rotate the value of my variable between "A", "B", "C"

Any ideas of how I would set up either a Visual Basic case or if else statement for this?
I have a series of ListBoxes I inherited. (Many)

I need to build a comma selerated string that I can pass into SQL Server

If a person selects Bob, Tim and Larry

strAccomName below would get built as

So that when I pass it ito SQL

It can be used  as
WHERE a.AccomName in (@strAccomName)

        For Each Item As ListItem In ddlAccomName.Items
            If Item.Selected Then
                strAccomName = strAccomName & Item.Value & ","
            End If

balh... blah... blah...
 oCom1.Parameters.Add(New SqlParameter("@strAccomName", SqlDbType.VarChar)).Value = strAccomName

blah... blah... blah...

I am also open to manipulating them on the SQL Server side.
I do not see any options to add Microsoft Reporting to Visual Studio 2013.  I need to add this and the report viewer control.  Thank you
My previous application in VB6 would create a record using the code below:


Module basDeclarations

Public Const maxTables = 20

Structure Gametype
    <VBFixedString(6)> Public memberID As String
    Public TableID As Integer
    Public StartTime As Date
    <VBFixedString(1)> Public Occupied As String
End Structure

End Module


Public Sub CreateCurrentGamesFile()
    Dim OneGame As Gametype
    Dim TableNumber As Integer
    Open app.path & "\CurrentGames.dat" For Random As #1 Len = Len(OneGame)
    For TableNumber = 1 To maxTables
        OneGame.memberID = ""
        OneGame.TableID = TableNumber
        OneGame.Occupied = "N"
        Put #1, TableNumber, OneGame
    Next TableNumber
    Close #1
End Sub
End Class

How can I convert this block of code in to create new records as a random access file? Or Is there a better way to store records which can be easily saved and deleted in Thanks

Please provide comments on your code
Hi all.

I have a combobox box that is used to enter data into a datagridview control. I want to be able to remove an entry from the combobox if it is already in the datagridview control. How can I do this?

Here's my code for populating the combobox box cmbGPO:
Private Sub cmbGPO_Enter(sender As Object, e As EventArgs) Handles cmbGPO.Enter

        Dim con As New SqlConnection
        Dim cmd As New SqlCommand
        Dim adapter As New SqlDataAdapter()
        Dim ds As New DataSet()

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


        cmd.Connection = con

        cmd.CommandText = "SELECT GPO FROM GPOs ORDER BY GPO"

        adapter.SelectCommand = cmd


        cmbGPO.DataSource = ds.Tables(0)
        cmbGPO.DisplayMember = "GPO"
        cmbGPO.SelectedIndex = -1
End Sub

Open in new window

Here's the code that populates the datagridview:
Private Sub btnAddGPOID_Click(sender As Object, e As EventArgs) Handles btnAddGPOID.Click
DataGrid_GPO.Rows.Add(cmbGPO.Text, txtEC.Text, txtTNumber.Text, txtTName.Text)
End Sub

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,