Visual Basic.NET

93K

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

VB.Net errorIm getting this error message and not sure if the sql command does not like the date or not?
0
Introduction to R
LVL 12
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

I have many G-Code files and I want to create a gallery like c# application that shows the previews/thumbnails of the G Code files.
In short: I want a G-Code to Image converter.

Can someone give me some direction?
Or can someone give me a source code from where can I start?

Thanks advanced
0
How would I be able to cycle through the following code and put together Keyboard entries to match the word "Go" from a barcode scan. The code bellow
takes the e.keychar by each key pressed. I want to use the code below to read a barcode scan that match the word "Go"
 Public Sub Runtime_Keypress(ByVal sender As Object, ByVal e As KeyPressEventArgs)
        Try
            Dim gageValues() As String
            Dim KeyboardInput As New System.Text.StringBuilder
            gageValues = CStr(CType(sender, Label).Tag).Split(",")
            If gageValues(0) = "Keyboard" Then
                If e.KeyChar = Chr(8) Then 'This is the backspace check
                    If CType(Me.readingLabelArrayList(sender.tabindex), Label).Text.Length > 0 Then
                        CType(Me.readingLabelArrayList(sender.tabindex), Label).Text = CType(Me.readingLabelArrayList(sender.tabindex), Label).Text.Substring(0, CType(Me.readingLabelArrayList(sender.tabindex), Label).Text.Length - 1)
                    End If
                ElseIf e.KeyChar = vbCr Then
                    mNewRuntimeMethods.calcOperations.PerformCalculations(mNewRuntimeMethods.tmpSavedInfo, readingLabelArrayList, pFile, mNewRuntimeMethods.intCurrentPartNumber, mNewRuntimeMethods.boolMinMaxStartButtonBeenPressed)
                    mNewRuntimeMethods.SampleData()
                    CType(Me.readingLabelArrayList(sender.tabindex), Label).BorderStyle = BorderStyle.FixedSingle
                    

Open in new window

0
I have written a vb.net service.  I would like to silently install a program using the service.

The program is silently installable... I can do it via the command prompt.

The service, however, doesn't install and I think the issue maybe the space in which the service runs.

Thoughts?
0
How can I double click on a text box and copy the contents in ASP.net Visual Basic. And please make your answer understandable and complete so I will be able to use it on my web site.
Thank you very much for any help you can give me.
Scott
0
My question is in regards to editing an xml document in vb.net and then saving the changed document. So I am looking for help from an expert who has worked with xml documents using vb.net or C#. My particular example is in VB.net

Example :
For my XML document below I have an xml document with different soccer teams, along with information related to the team.
I just want to be able to read through the document and change values in the file an re-save it.

My approach below is that I read the document into an XMLNodeList. In my example I am changing the city name using .innerText assignment. So once my XMLNodeList object has been edited, how do I save it back to an XML document format with the same structure as the original XMLDocument?


Dim cfg As New XmlDocument()
Dim myNode As XmlNode
Dim myList As XmlNodeList

cf.Load("Teams.xml")
Dim myList As XmlNodeList
myList = cfg.SelectNodes("descendant::Category/Item")

for Each nd As Xml.XmlNode in myList

If nd.InnerText = "City" Then
nd.InnerText = "AllTheSame"

End If
 
Next



<?xml version ="1.0" standalone ="yes"?>
<Settings xmlns:xsi="http://www.w3.or/2001/XMLSchema-instance">
<Category name="Soccer">
<Item name = "TeamName">ThunderBolts</Item>
<Item name = "City">Toronto</Item>
<Item name = "Captain">Farver</Item>
</Category>
<Category name="Baseball">
<Item name = "TeamName">Mavericks</Item>
<Item name = "City">Los Angeles</Item>
<Item name = "Captain">Buckley</Item>
</Category>
0
In Visual Studio Professional 2015, if there's an runtime error in the form load event of a vb.net application, the form continues to open without running the rest of the code, and I don't see a report of any error in either the immediate window or the error list window.  I tested this by purposefully setting a connection object with an incorrect connection string.  How can I get the program to halt and give me an error message instead of skipping the rest of the code and opening the form?
0
Conversion from string " " to type 'Integer' is not valid.'

Dim lines() As String
        Dim file As String
        file = "C:\Files\file.txt" 
        Dim sr As New StreamReader(file) 

        lines = sr.ReadLine().Split(vbTab) 

        For Each line In lines

            staffName(line) = lines(0)
            StaffNo(line) = lines(1)

        Next

Open in new window

0
Have just installed Visual Studio 2017. Creating a Windows Form in VBasic I can add items such as a 'button' but when I double click the item to add code it does nothing. I am new to Visual Studio so not sure what to look for.
0
Using Constructs with arrays

Dim myFile As New System.IO.StreamReader("H:\Files\myfile.txt")
        Dim i As Integer
        While myFile.Peek() <> -1
            Dim myString As String = myFile.ReadLine()
            Dim obj As String() = myString.Split(","c)
            staffName(i) = obj(0)
            StaffNo(i) = obj(1)
            i = i + 1
        End While

' gives out of bound error, why?
0
Bootstrap 4: Exploring New Features
LVL 12
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

Hi

I am using the following code in ASP.net (VB.net) to read the contents of a spreadsheet
into a dataset. Instead of specifically reading "Sheet1" how would I adjust the following
line to just read the first sheet?
sql = "SELECT * FROM [Sheet1$]"

    Public Function Read_Excel_Into_DataSet() As DataSet

            Dim sMinAndSecond As String = Me.Second_Minute_of_Upload.Text 'workaround to 

            Dim connetionString As String
            Dim connection As OleDbConnection
            Dim oledbAdapter As OleDbDataAdapter
            Dim ds As New DataSet
            Dim sql As String
            Dim i As Integer

            connetionString = "Provider=Microsoft.Jet.OLEDB.4.0;" &
             "Data Source=" & Server.MapPath("~/Temp/Excel_Import" & sMinAndSecond & ".xls") & ";" &
             "Extended Properties=""Excel 8.0;HDR=YES;IMEX=1"""

            sql = "SELECT * FROM [Sheet1$]"

            connection = New OleDbConnection(connetionString)
            Try
                connection.Open()
                oledbAdapter = New OleDbDataAdapter(sql, connection)
                oledbAdapter.Fill(ds)
                oledbAdapter.Dispose()
                connection.Close()


                Return ds
            Catch ex As Exception
                MsgBox("Can not open connection ! ")
            End Try



    End Function

Open in new window

0
Hi

I am using the following VB.net code on my ASP.net web form to populate an Excel spreadsheet
from a data table. At the moment the sheet name is derived from the SQL table that
the data table was pulled from. I need the sheet name to be "Sheet1". How do I do this

    Public Sub ExportToExcel_AsXlsFile(ByVal dt As DataTable, ByVal file_name As String)
        Dim grid = New GridView()
        grid.DataSource = dt
        grid.DataBind()
        Response.ClearContent()
        Response.Buffer = True
        Response.AddHeader("content-disposition", "attachment; filename='" & file_name & "'.xls")
        Response.ContentType = "application/ms-excel"
        Response.Charset = ""
        Dim sw As System.IO.StringWriter = New System.IO.StringWriter()
        Dim htw As HtmlTextWriter = New HtmlTextWriter(sw)
        grid.RenderControl(htw)
        Response.Output.Write(sw.ToString())
        Response.Flush()
        Response.[End]()
    End Sub

Open in new window

0
In vb.net, how can I create recordset from multiple datatables?  For example, if I want to use a left join between two datatables to see all records in one datatable that don't have a matching record in another datatable, how would I do that?  I know that if I create a connection object to a SQL Server or Access database then I can then use a command object based on that connection object to specify a SQL statement that includes a left join between two tables in that remote database.  Can I create a connection object to connect to a local dataset resident in the memory of the .net application?  If so, can I base a command object on that connection object and specify the names of datatables in that dataset in a SQL statement of that command object?
0
Hi

I am using the following vb.net code to loop through a data set. In certain cases there is no column called "Type"

How do I check if the column "Type" exists before trying to read it?

     For Each row As DataRow In ds.Tables(0).Rows

                If Not row.Item("Type").Equals(DBNull.Value) Then
                    oType = Convert.ToString(row.Item("Type"))
                Else
                    Exit Function 
                End If

                If Not row.Item("Category").Equals(DBNull.Value) Then
                    oCategory = Convert.ToString(row.Item("Category"))
                Else : oCategory = "Null"
                End If
     Next

Open in new window

0
Hi all.

I have a VB.net chart that displays sales stages and the count for each sales stage. I want to be able to allow the end user to double click the X-axis label, which is the sales stage, and save that value in a variable. Unfortunately, I haven't been able to do so. Below is some of the code, I'm trying to show it in a messagebox for now, I've been playing with but unable to get it to work. I basically want to get the axislabel when it's double clicked.

Private Sub Chart1_MouseUp(sender As Object, e As MouseEventArgs) Handles Chart1.MouseUp
 Dim HTR As HitTestResult
       HTR = Chart1.HitTest(e.X, e.Y)
Dim h As HitTestResult = Chart1.HitTest(e.X, e.Y)
If h.ChartElementType = ChartElementType.AxisLabels Then
Dim dp As DataPoint = Chart1.Series("Stages").Points(h.PointIndex)
MsgBox(dp.AxisLabel)
End If
 End Sub

Open in new window


I was able to get this to work by clicking the datapointlabel instead of the axislabel, but ultimately I would like it to work for the axislabel. See code below:

Private Sub Chart1_MouseUp(sender As Object, e As MouseEventArgs) Handles Chart1.MouseUp
Dim SelectDataPoint As DataPoint
Dim h As HitTestResult = Chart1.HitTest(e.X, e.Y)
If h.ChartElementType = ChartElementType.DataPointLabel Then
SelectDataPoint = CType(h.Object, DataPoint)
            MsgBox(SelectDataPoint.AxisLabel.ToString)
End If
 End Sub

Open in new window

0
Hi

In my ASP.net web app I want to use VB.net code to hide a menu bar with the ID of "Menu1"
on mobile devices on page load.
What VB.net code would I use to do this?

Thanks
1
I migrated vb6 to vb.net using the vs2008 wizard and it works fine But some controls are not visible on form.
 I can see them on control list in properties window but can not get them to be seen on the form in design time.
what am I missing?...
0
Hi experts, I am using Microsoft.Office.Interop.Owc11.dll in my vb.net project
some properties dont work as expected and im looking for solutions:

ReportForm.Spreadsheet11.ActiveSheet.Range("a1:" & Chr(intReportColumns - 4 + 65) & 1).MergeArea.HAlignment = OWC.SheetHAlignEnum.ssHAlignCenter

ReportForm.Spreadsheet11.ActiveSheet.Columns(i).AutoFitColumns()

Thanks in advanced
0
What is the best option to interface SQL with Visual Studio's  .NET. I have a project that require connection to a SQL data.

If I wanted a free SQL download. where could I find it?
0
Microsoft Azure 2017
LVL 12
Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Hi,
What is the meaning of Annotate (Blame) in GitHub
I am using visual studio 2017.

Thanks in advance.
0
How to I and what namespaces do I need to call an Web API using VB.net or C#.

I want to populate a dropdown list with the json file passed to my app fro my webAPI.

Isaac
0
lowercase letter = "mon" to "npo"  ASCII

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
     Dim shift As Integer = 1
     Dim asciiValue As Integer = 0
     Dim wordConverted As String = ""
     Dim word As String

     word = "mon"  ' InputBox("Please enter word to convert")

     For Each c In word
         asciiValue = Asc(lcase(c))

         '#check it's not 'Z'!
         If asciiValue <= 121 Then
             asciiValue = asciiValue + shift
         Else
             asciiValue = 97
         End If

         wordConverted = wordConverted + Chr(asciiValue)
     Next
     MsgBox(wordConverted)
 End Sub
0
Change the word from MON to NPO

I get NOP which is incorrect

    Dim shift As Integer = 1
        Dim asciiValue As Integer = 0
        Dim wordConverted As String = ""
        Dim word As String
 
        word = InputBox("Please enter word to convert")
 
 
 
        asciiValue = Asc(word)
 
        For Each c In word
 
            '#check it's not 'Z'!
            If asciiValue <= 89 Then
                asciiValue = asciiValue + shift
            Else
                asciiValue = 65
            End If
           
            wordConverted = wordConverted + Chr(asciiValue)
 
 
        Next
        MsgBox(wordConverted)
0
Hello,
How to find the index of the item in the listbox.

Dim items = From i In lstbox.Items Where i.ToString().StartsWith("Al")

        If items.Count > 0 Then

        Else

        End If

Open in new window

0
Im looking for a way with VB.NET or something similar to keep a particular webpage refreshing in the users chosen web browser on a timer to basically prevent a timeout where they got logged out and are required to log back in to a web portal from an external provider. Is there a way to tell a web browser application to refresh a tab externally either by the url or the name of the tab ? Im thinking that using a vb app to browse the website wouldn't work because its outside the browsers context where the user authenticated and would not achieve what im after. Any ideas or a completely different approach maybe ?
0

Visual Basic.NET

93K

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,