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 form in html how to declare a codebehind in vb.net in the submit button in order to store the fields data on database?

regards
0
On Demand Webinar: Networking for the Cloud Era
LVL 9
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Is there a way to retrieve Mapped Network Drives using Visual Basic .NET?

The following command retrieve some drives; however, it does not return the Mapped Network Drives.

IO.DriveInfo.GetDrives
0
We are reading a specific text file and  outputting it with new data, but noticed that the  output file doesn't get  created  and even less, no data seems to be exported.  We went step by  step and there is no error.

Please advice on what's missing in  the below code so it  can export the variable 'zFullPath'.

Code:
Imports System.IO
Public Class Form1
    Private Sub cmdExportIt_Click(sender As Object, e As EventArgs) Handles cmdExportIt.Click
        Dim inFilePath = "C:\temp\pIN.txt"
        Dim Vars, PrevPathname, zPathname, zFilename, zAllData, zFullPath As String
        PrevPathname = "blank"
        For Each Line In File.ReadLines(inFilePath)
            If Microsoft.VisualBasic.Left(Line, 13) = " Rans)(*&" Then
                zPathname = Replace(Microsoft.VisualBasic.Right(Line, Len(Line) - 14), txtExtractDrive.Text, "")
            Else
                zPathname = PrevPathname
            End If
            PrevPathname = zPathname
            If Mid(Line, 3, 1) = "/" Then
                zFilename = Microsoft.VisualBasic.Right(Line, Len(Line) - 39)
                zAllData = zPathname & "_" & zFilename 
                zFullPath = zPathname & vbTab & zFilename & vbTab & zAllData
                File.WriteAllText("C:\temp\pOUT.txt", zFullPath)
            End If
        Next
    End Sub
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub
End Class

Open in new window

0
i have changed an old  windows application made in VB to website in c#.Both are referring a same vb dll code.for that particular dll code, Both the applications show sometimes the out of string space error and we are fine with that. But the freqency of out of string space error is very high for website comparatively of windows application. This code generates a report. so it first write the data from database into an xml file and then generates a word file. while writing that xml,this error comes.
I have checked for the same object ,in windows application it took 6-7hours but finally it gives the report. While in website in around 1 hour it gives out of string space error.
What cold be the reason ?
0
I want to use WIA objects in my projects through late binding.
0
What are some good websites to help keep me current with the latest and greatest for C#.NET Full Stack development?
0
Hi Experts,

My customer needs a report like this(Please see the attached report). How to create something like this. I have all the Data. I am using ASP.Net, VB.Net and RDLC reports. Please help.

Thanks in advance.
BGMenu.png
0
Can EE give us samples of how to read in a text file line by  line in Visual Basic 2017.
0
I am developing a printserver app and on the oldest Print Server is a windows 2003 server. When you query the Print Server for desiredn values instead of a straight IP Address you get for example IP_168.112.75.11 i NEED TO LOSE THE IP_ so I can access the network printer's web interface. I Know there's a replace command but I'm just looking for a quick answer that works I know this is easy for you Experts Please in VB.NET CONTEXT.
2003 SERVER


Thanks EE you guys kick ass.
2003pRINTSERVER.png
0
We have an older Windows server (Contract) and I need some vb.net code that looks at the C: drive and gets me a simple GB and %free remaining

example...
10.25 GB and 25%free
0
Enroll in July's Course of the Month
LVL 9
Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

A = Freefile()   'A is 1
Fileopen (A, File1,......

FileClose(B)    'B is not set yet BUT File1 is Closed !!!!
B = Freefile()   'B is 1  because file1 is closed !!!!!

FileGet(A .......    'gives an error (Bad file name or number)

closing an unopened file causes closing a previously opened file!!!!
Any body noticed this issue? or there is something I missed?
0
The following code has two counters. One runs directly from the form (in the main thread) and another is performed by a BackgroundWorker. Interestingly, the two counts do occur at the same time (which is the intent...win!) but the progressbar doesn't change at all until after the BackgroundWorker has finished. Of course, I'd like the progressbar to update during the counting. Help?

Note: The code below is just a test I'm performing so I can take the structure and expand it to a real-world, time-consuming, stored-proc.
Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.ProgressBar1.Maximum = 10
    End Sub

    Private Sub btnHeavyTask_Click(sender As Object, e As EventArgs) Handles btnHeavyTask.Click
        Debug.Print("Starting to count now")
        BackgroundWorker1.WorkerReportsProgress = True
        BackgroundWorker1.RunWorkerAsync()
        mainThreadTask()
    End Sub

    Private Sub mainThreadTask() 
        Dim i As Integer = 0

        Do Until i = 15
            Me.txtHeavyTask.AppendText(vbCrLf + i.ToString)
            Me.txtHeavyTask.Refresh()
            Threading.Thread.Sleep(500)
            i += 1
        Loop

        Me.txtHeavyTask.Text = "Done"
    End Sub

    Private Sub BackgroundWorker1_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork
        Dim i As Integer = 1

        Do Until i = 10
            

Open in new window

0
How to save all my listview item to arrays ?
0
Hi,

I have just started trying to learn Visual Basic 2015 and the book I am using has in the code instructed me to use the following code :

"Val" to convert a text string; and
"Me" to reference the current form

Neither of which are recognisied by Visual Basic 2015.

    private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Sum.Text = Val(Num1.Text) + (Val(Num2.Text));
        }
    }
}



  public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Me.Text = InputBox("Enter a Caption...")
        }

    }
}
0
I have a screen that a user can either enter information(about 5-6 fields) and click Add Item or they can enter in an ID(one of the fields) and click Search and it will populate all the other fields. This works great. I had RequiredFieldValidators for the fields that are mandatory(all of them) and I noticed that when I tried to do a search that the fields would have the validation messages next to them and it would never hit the code behind for the search button. Obviously the validator is working on the client side and doing its job but it wouldnt let the server side code to run? I want to have the functionality of the search button to fill the fields with data and for the RequiredFieldValidators to work when the Add Item is clicked.
 Now, I read where you can set EnableClientScript="true" in the validators(client side) and that allows the server side code to run when I click Add Item but then the validators are allowing missing fields. I tried to set the EnableClientScripts back to false but when I test and click Add Item, with no data, its saving a blank record and thats not cool!!!
Any thoughts on this? Any help would be appreciated!!!

Thanks
JK
0
Hi EE,

in vb.net, I have a TreeView control.

each nodes (lets say I have 5) like this :

Apples
Tomatoes
Oranges
Grapes
Bananas


each of them has an "ID" or a "Code" in the background.  lets say its :

Apples     [0020]
Tomatoes   [0025]
Oranges     [0060]
Grapes     [0061]
Bananas    [0110]


My 2 questions are :

1) If I have a button "Add item" is it possible to add a node at the end of the tree, the user writes the name of the fruit, then he could drag the new node somewhere in between 2 fruits to place it where he wants it ?

2) since there are codes to each fruit, if user drags it in between [0025] and [0060] I would like the code to be automatically created at 0026 to be placed in between !

But it goes to another question, what If after the user creates another one and wants to place it in between of 0025 and 0026 ? now there is not space anymore between the codes ! we would have to increment of + 1 all the codes then place it in between.

so thats my issues... I realyl need help on this...
thank you.

(I am using fruits as an example but this is for work in our Logistic menu in our system. right now its not efficient, I have created the TreeView and reading values from SQL, but im stuck there for the rest)
0
Hi

I use the following code to dynamically edit a SQL table in a Windows Form DataGridView.
Most of the time things work but around one out of every 5 times I get the error shown in the image below.
Why would this be? Is there a better way to dynamically update a SQL table based on changes made by the user?

    Sub oDynamic_SQL_Save()
        Try

            Dim builder As New SqlCommandBuilder(dbadp2)

            builder.QuotePrefix = "["
            builder.QuoteSuffix = "]"

            dbadp2.UpdateCommand = builder.GetUpdateCommand()

            dbadp2.Update(dTable2)
            dTable2.AcceptChanges()

        Catch ex As Exception
            MsgBox(Err.Description & " mmm")
        End Try
    End Sub

Open in new window



Image1
0
Dear Experts,

Can anybody help me to sort out the issue?

Issue Description : I need to get the textbox entered value in gridview at the time of linkbutton click event.

Design Page :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="prefLine"
                                                    AllowPaging="True" AllowSorting="True"
                                                    OnPageIndexChanging="GridView1_PageIndexChanging" Width="100%" BackColor="White" BorderColor="#999999" EnableModelValidation="True" GridLines="Vertical">
                                                    <Columns>
                                                        <asp:TemplateField HeaderText="Edit" >
                                                            <ItemTemplate>
                                                                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#String.Format("frmSls.aspx?id={0}&det={1}", HttpUtility.UrlEncode(Eval("nSlsID").ToString()), HttpUtility.UrlEncode(Eval("nSlsDetID").ToString())) %>'
                                                                    Text="Edit" CommandName="select">
                                                                </asp:HyperLink>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        

Open in new window

0
Hi all. I have a windows form created in vb.net (visual studio 2013) that is displaying the following error:

Conversion from type 'DBNull' to type 'Decimal' is not valid

In the following code:
Dim frm As New ContractEditItem
 frm.stdcost = DataGridDetails.SelectedRows(0).Cells("StdCost").Value

Open in new window


When the StdCost cell in the DataGridDetails datagrid is null. The StdCost cell is of type Decimal and the frm.stdcost variable is also of type Decimal.

There are times when records do not have a stdcost and there are times when it does.

First question: How can I fix this error?
Second question: There may be times when the end user will do some changes to some other fields and then click a Save button which will insert records into a table and the stdcost field may be null and this is ok for our systems, will I also get an error when that happens?

Thank you in advance.
0
PeopleSoft Has Never Been Easier
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Hey I am working on a Windows App in Vb.net where I load a Dropdown box and a Listview with Printers from a Printserver.
I can do this if it were pulling data from a database but  the goal is to type in dropdown the Printername and dropdown autocompletes like a Google Search My Challenge is when dropdown is selected I want listview to filter to the name in dropdown.
Here is the visyuals and code. I don't know how to sort to printer in listview.
Printer App with dropdown wanting to sort to the desired Printer NAMEHere are the Print names next to Icon of Printer
Print App displaying all the Printers.
  Public Sub Printers()
        Dim options As ConnectionOptions
        options = New ConnectionOptions
        options.Username = "xxxxxx"
        options.Password = "xxxxxxxxxxxx"
        LSPrinters.Clear()
        '* Test the connection


        '  Dim ps() As Services
        LSPrinters.BeginUpdate()

        LSPrinters.Columns.Add("", 150, HorizontalAlignment.Center)
        LSPrinters.Columns.Add("Name", 150, HorizontalAlignment.Left)
        LSPrinters.Columns.Add("DriveName", 250, HorizontalAlignment.Left)
        LSPrinters.Columns.Add("Location", 250, HorizontalAlignment.Left)

        LSPrinters.Columns.Add("Port Name", 200, HorizontalAlignment.Left)
        ' LSPrinters.Columns.Add("Document", 150, HorizontalAlignment.Left)
        ' LSPrinters.Columns.Add("Jobstatus", 150, HorizontalAlignment.Left)
        '' LSPrinters.Columns.Add("PagesPrinted", 150, HorizontalAlignment.Left)
        ' 

Open in new window

0
so its a basicaly a complaint form ,if the complaint is solved it should remove the row automatically from datagridview
0
Hey

How do I connect to a SQL server - and return a recordset? (Trusted_Connection=True)

For example (Select * from mytable where field1=1)

Using VB.NET

Thanks in advance

Mike
0
Hi,
 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"

 

        'Try

        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)

        Cmd.ExecuteNonQuery()

        ' 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.
0
Hey

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

Mike
0
I have a subdomain subdomain1 in a primary domain maindomain1.com
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("http://www.subdomain1.maindomain1.com/myfolder" , mylocalfilefullpath)

I am getting error 404 (non existing folder or file. What Am I doing wrong. Thanks for the help
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,