[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

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

My requirement is to convert below pipe delimited  text (input.txt) file into an excel file (.XLSX) using VBScript .
 
Here is example of my text input file :-

input.txt (attached for reference)

Name|age|gender|department|year

don|23|male|computer|2010
ptalakes|24|female|maths |2015
chang|28|male|arts |2016
prag|29|female|science |2018
tom|26|male|arts |2017
john|27|female|sports |2018
simon|22|male|arts |2018

Output file  (output.xlsx attached )  should be saved in excel file as below in corresponding cell :-


Name      age      gender      department      year
don      23      male      computer      2010
ptalakes      24      female      maths      2015
chang      28      male      arts      2016
prag      29      female      science      2018
tom      26      male      arts      2017
john      27      female      sports      2018
simon      22      male      arts      2018



Would appreciate if some one could please help me to get complete code in vbscript.

Thanks in advance
Praveen
Input.txt
output.xlsx
0
JavaScript Best Practices
LVL 12
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Good morning, I have a Windows Form (vb.net) and I am dynamically creating multiple DateTimePicker controls. The number of controls depends on how many employees are currently registered in the database. So for each employee they get a start and end time control for their schedule. I have read multiple articles and solutions and I am simply stuck. I need 1 handler to fire anytime a timepicker value is changed. Once the value is changed, the textbox next to it will show the timespan in hours that will be added to the schedule...

Any help would be great
Dim DateTimePicker As New DateTimePicker
                DateTimePicker.Name = "Start" & counter
                DateTimePicker.Size = New Size(80, 25)
                DateTimePicker.Location = New Point(Combo2.Location.X + 135, Combo2.Location.Y)
                DateTimePicker.ShowUpDown = True
                DateTimePicker.Value = "1/1/2018 06:00 AM"
                DateTimePicker.Format = DateTimePickerFormat.Custom
                DateTimePicker.CustomFormat = "hh:mm tt"
                Me.Panel2.Controls.Add(DateTimePicker)

                Dim DateTimePick As New DateTimePicker
                DateTimePick.Name = "End" & counter
                DateTimePick.Size = New Size(80, 25)
                DateTimePick.Location = New Point(DateTimePicker.Location.X + 90, DateTimePicker.Location.Y)
                DateTimePick.ShowUpDown = True
                DateTimePick.Value = "1/1/2018 12:00 PM"
                

Open in new window

0
Hi Expert,
Technical Documentation is writing before development/Project start or after completed the project?
0
Good morning everyone! I am creating a system for work and part of that system is viewing a weekly schedule. Essentially I have a Windows Form that I dynamically create text-boxes for each employee in our database. Then for each box, it generates 7 more boxes for each day of a full week. I do this so I can add new employees to the database and the schedule auto generates the information. Anyways, I have a dynamically generated combobox at the top that holds dates of the current month and those dates represent every Monday of the month. I want the schedule to extract dates between the selected combobox item and that value +7 days...I ran the debugger and on the line that attempts to pull the date from the combobox I get an "object reference not set to an instance of an object". Here is my current code

This block creates the combobox and sets its properties
 Dim combo As New ComboBox 'Create a new combobox for the form
        combo.Name = "ComboBox1" ' set the combobox name as "ComboBox1"
        combo.Size = New Size(152, 35) 'Set the ComboBox Size to the same as the textboxes below
        combo.Location = New Point(20, 19) ' Set the combobox ontop of the textboxes
        combo.FormattingEnabled = True 'enable formating so the date is a shortstring
        combo.FormatString = "MM/d/yyyy" ' set the desired format
        Me.Controls.Add(combo) ' add the control to the form
        Dim Date1 As Integer = DateTime.DaysInMonth(Now.Year, Now.Month) 'Set date1 as 

Open in new window

0
Hi all,
I'm having a problem reading in an RDLC xml file.  My purpose is to collect information about the dataset(s), e.g. Dataset Name and Table name.
I've been dealing with xml projects for decades and for some reason every piece of code I try returns nothing.
Try
            Dim xmlDOC As New XmlDocument()
            xmlDOC.Load(XMLFILE)

            Dim nodeList As XmlNodeList = xmlDOC.SelectNodes("/Report/DataSets/DataSet")
            MsgBox(nodeList.Count)
            For Each node As XmlNode In nodeList
                MsgBox("DataSet Name: " & node("Name").InnerText)
            Next



        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

Open in new window

0
I am teaching myself visual studio with visual basic. Please help a newbie.

I have a connected sql table setup as follows
TABLE [dbo].[Suffix](
      [SuffixID] [int] IDENTITY(1,1) NOT NULL,
      [Suffix] [nvarchar](3) NOT NULL,
      [myCount] [nvarchar](5) NULL,
 CONSTRAINT [PK_Suffix] PRIMARY KEY CLUSTERED

I created a visual basic windows form in visual studio.  the save button on the form as the following code behind it in the click event.
            cmd.CommandType = System.Data.CommandType.Text

            cmd.CommandType = "insert into Suffix values ('" & TextBox30.Text & "', '" & TextBox28.Text & "')"
cmd.Connection = con
            con.Open()
            cmd.ExecuteNonQuery()
            MsgBox("Succesfully added", MsgBoxStyle.Information, "add")
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try

I keep getting the following error Conversion from string "insert into suffix value ('txx'" to type 'integer' is not valid.

How do I fix this?
0
I have a simple macro (see below) for an access 2013 database that has you can see prompts for a message box to inform the user to select a check box (called "complete trans"). The problem is a good portion of our folks forget to check the box (go figure). What I would like to do is have the box automatically checked once they select ok on the message box. What is the line of code to accomplish this? Below is my macro.

Option Compare Database

'------------------------------------------------------------
' Macro1
'
'------------------------------------------------------------
Function Macro1()
On Error GoTo Macro1_Err

    DoCmd.RefreshRecord
    DoCmd.OpenQuery "Append History Database", acViewNormal, acEdit
    DoCmd.RefreshRecord
    Beep
    MsgBox "UNCHECK THE ""COMPLETE TRANSACTION"" BOX BEFORE PROCEEDING.", vbCritical, "SE-SELECT CURRENT RECORD"

Macro1_Exit:
    Exit Function

Macro1_Err:
    MsgBox Error$
    Resume Macro1_Exit

End Function
1
Hello,
Any suggestion on how I can use Adobe in my vb.net app  to generate PDF from system.bytes(memory Stream).

Thanks
0
Hello,

I am using vb.net desktop app.
The requirement is to create PDF document from memorystream (system.bytes) data extracted from SQL Server. We have a table which saves images in bytes in sql datatabase.
I need to create PDF document from the memorystream.
I have tried PDFsharp , it does give me one page PDF but struggling to get multipage from it.
I am open to any software suitable.
The code I used with PDF sharp is this :
 Dim dtSQLImage As New DataTable
        Dim imagedt
        Dim imageData() As Byte

        Dim unicode = PdfFontEncoding.Unicode
        Dim embedding = PdfFontEncoding.Automatic

        Dim clsFrmain As New ClsFrmMainLoad

        dtSQLImage = DgFinanceImg.DataSource
        Dim pdfRenderer As PdfDocumentRenderer = New PdfDocumentRenderer(unicode, embedding)
        For j = 0 To dtSQLImage.Rows.Count - 1
            If j = DirectCast(sender, Telerik.WinControls.UI.RadGridView).CurrentRow.Index Then
                imageData = (dtSQLImage.Rows(j)(0))

                For i = 0 To 2

                    imageFilename = MigraDocFilenameFromByteArray(imageData)
                    document = New MigraDoc.DocumentObjectModel.Document
                    Dim pageSetup As MigraDoc.DocumentObjectModel.PageSetup = document.DefaultPageSetup.Clone
                    ' set orientation
                    pageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape
                    Dim section As 

Open in new window

0
I have a drop down list using vb.net.  I want to refresh the drop down list if not
completed or another drop down list is selected ie I want the drop down list to display
the initial settings not where I let off when last visited.  At this time if I hit the refresh
button, the values are reset.  How can I reset in code and the best place to do this in code.

Currently from what I see so far the app is using session close.
0
PMI ACP® Project Management
LVL 12
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

Hello Experts.

I have learned from past experience that it can be hazardous to make changes to a back-end data table when it is bound to an existing VB.NET project in Visual Studio.

I would like to believe that it is possible to pull this task off without crashing my project, and would like to seek any advise from the EE community on how to do this.

Specifically, I have a single MDB file which contains a dozen or so tables and queries/views, with all their relationships. Everything is created/designed using MS Access 2016.

I want to change the primary key on one of the tables within that MDB. That would also require removing some of the relationships, and establishing new ones as needed.

Right now, the primary key for the Roster table is sequentially assigned, but the first non-primary field is and always will be unique, so I would really like to change it.

So, I am looking for some step-by-step instructions from someone who has successfully done this within the context of a previously bound Visual Studio project.

As always, don't hesitate to ask if I've left any important details out.

Thanks,
Tony G.
0
Hello,
How do I select multiple files in vb.net .The code i am currently using is ;
 Public Function ReturnWordTemplatePath() As String
        '//***This Function return the path where word file template is located ***\\
        Dim strresponse As String
        Dim WordTemplate As String
        ' Dim str As String = "LArrDep"
        Dim dlg As New OpenFileDialog()
        ' Filter by Word Documents

        dlg.Title = "Select Ac to attach"
        ' dlg.FileName = str
        dlg.AutoUpgradeEnabled = False
        strresponse = dlg.ShowDialog(Me)
        Application.DoEvents()
        If strresponse = 1 Then
            Application.DoEvents()
            WordTemplate = dlg.FileName
            Return WordTemplate
        End If
        Return String.Empty
    End Function

Open in new window


Cheers
0
In this example from this post

https://www.experts-exchange.com/questions/29119837/clearing-a-Header-Row-CheckBox-in-a-DataGrid.html

My DataGrid looked like this:

p1.PNG
Notice my CheckBox column is the 1st column of the DataGrid

My button click event looked like this, this worked fine:

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        ' reset header checkbox
        Dim dgHeader As DataGridItem = DGEmployees.Controls(0).Controls(0)
        Dim targetChkBox As CheckBox = dgHeader.Controls(0).Controls(1)
        targetChkBox.Checked = False
        CType(DGEmployees.Controls(0).Controls(0).FindControl("DataGridEmployees_SelectAll"), CheckBox).Checked = False

    End Sub

Open in new window



In these 2 lines of code:

        Dim dgHeader As DataGridItem = DGEmployees.Controls(0).Controls(0)
        Dim targetChkBox As CheckBox = dgHeader.Controls(0).Controls(1)

What are these references?

.Controls(0).Controls(0)
.Controls(0).Controls(1)

Is that the first row and 1st column?

So if my datagrid looked like this (the checkboxcolumn is the 6th column of my datagrid),

p2.PNG
How do I reference the 6th column of my datagrid?

I tried this but it didn't work,
    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

        ' reset header checkbox
        Dim dgHeader As DataGridItem = DGEmployees.Controls(0).Controls(0)
        Dim targetChkBox As CheckBox = dgHeader.Controls(0).Controls(6)
        targetChkBox.Checked = False
        CType(DGEmployees.Controls(0).Controls(0).FindControl("DataGridEmployees_SelectAll"), CheckBox).Checked = False

    End Sub

Open in new window


I get this error message:

Specified argument was out of the range of valid values.
Parameter name: index
0
I have a DropDownList with AutoPostBack = True and set with Handles ddlExportOption.SelectedIndexChanged
I do not have this event also in code in front, only attached with a Handles to the event.

When I change the value it triggers as expected.

When I  change another postback, it still triggers the event.

Does anyone have an example of how you used a DropDownList with an AutoPostBack and that you have got it to NOT trigger when it is NOT the control being changed?

What I #1 would like is not a bunch of "have you trieds" but a known, working solution.

Apparently this is a known issue as I have read and tried numerous things suggested in forums. None of which work.

So that you won't ask "Have you tried...?" Here is what I've tried.

UpdatePanel with AsyncPostBackTrigger on controlId and event name.
DataBind on control on every postback.
Adding EnableViewState="true" to the control and to the page.


I've tried combinations of each of the above.

I've read to try ControlState and Override LoadPostData  if I don't wish to EnableViewState. Which I don't mind if I EnableViewState or not, it's just that when I do have it enabled, it still does the postback event anyway and has other unwanted results which I won't go into.

And again...

Does anyone have an example of how you used a DropDownList with an AutoPostBack and that you have got it to NOT trigger when it is NOT the control being changed?

What I #1 would like is not a bunch of "have you …
0
Hello,

How to export image to PDF995. I am using vb.net 2017 desktop.

Thanks in advance.
0
Hi,
How can i merge a image in an pdf with adobe pro in vb.net.
Any suggestions are appreciated.

Thanks
0
we are going to migrate a vb6 project to vb.net or c#.net. I want to use a converter tool at least for the screen drawings. did anynoe try  Microsoft Visual Studio 2008 expressfor that purpose?
0
Below is some VB.net code which will read in a single line of text and ten break/parse it up into strings based upon a delimiter.
The line of text is delimited by tabs.

My situation here is that the "vbTab"  constant is not being recognized as a tab after I set it at  line 3 below. When the split occurs on line 5, the split is not equating vbTab to the tab in
the data which has previously been saved into MystringToRead.

Why isn't vbTab being recognized? If instead of vbTab, if I just create two double quoutes and tab inside of them, then the tab control will get recognized.
In other words if I replace line 3 below with this line :  textParser.SetDelimiters("  "),
 it works. In this case I just added two double quotes, placed my cursor between them, and pressed the tab button.

So why isn't VB.net recognizing the vbTab command? I also tried "\t", but it is also not getting recognized as a tab in VB .net.





1. Dim textParser As TextFieldParser = New TextFieldParser = New TextFieldParser(New System.IO.StringReader(MystringToRead))
2.  textParser.TextFieldType = FieldType.Delimited

3.  textParser.SetDelimiters(vbTab)

4.  Dim recordAllSplitUp As String() = Nothing

5.  recordAllSplitUp = textParser.ReadFields
0
I have written an application that runs as a Windows Desktop application , running on a windows 10 laptop that occasionally crashes. The crash may happen after 24 hours, maybe 60 hours - maybe longer, sometimes not at all.
The Widows Event Viewer shows that the application crash was preceded by an Error from the ,Net Runtime- at around a minute before athe application is reported to have crashed.

Is this an application error or due to the KERNELBASE.dll? Or something else!

The details of the error are:

Log Name:      Application
Source:        Application Error
Date:          24/09/2018 01:20:16
Event ID:      1000
Task Category: (100)
Level:         Error
Keywords:      Classic
User:          N/A
Computer:      C-035
Description:
Faulting application name: MyApplication.exe, version: 2.0.7.10, time stamp: 0x5ba4b1a1
Faulting module name: KERNELBASE.dll, version: 10.0.17134.1, time stamp: 0x149ab0fd
Exception code: 0xe0434352
Fault offset: 0x0010d722
Faulting process ID: 0x1958
Faulting application start time: 0x01d451f2970b38f1
Faulting application path: C:\Program Files\Company1\MyApplication.exe
Faulting module path: C:\Windows\System32\KERNELBASE.dll
Report ID: 212dc380-af79-47ed-9362-dc496bd13999
Faulting package full name:
Faulting package-relative application ID:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
  <System>
    <Provider Name="Application Error" />
    <EventID …
0
OWASP: Threats Fundamentals
LVL 12
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

<%

If (XYZ IsNot Nothing) Then 

 Response.write(XYZ)

End If

%>

Open in new window

This gives me an error:

Server Error in '/' Application.
Object reference not set to an instance of an object.


How can I test if XYZ is actually defined?
0
Hello,
I am using vb.net desktop. Any suggestions on how to select a file and save a copy to a particular folder,

Thanks in advance.
0
ASP.NET Web form app with VB.NET back end code.

Is there a way in the RowDataBound event in VB.NET to change the Font used for just a single column in the GridView control?

I have a GridView bound to a data source and for the a single column only in the GridView I want to use the Wingdings3 font so I can put the triangle symbol in that column.
Example of label/legend on form:
Wingdings3.PNG
Here is my code that I just started changing the first nested IF.  The line I added for the Font change is incorrect syntax.  What would the syntax be?
I don't need to do it at the cell level necessarily if there is a way to change the whole single column to that font too, that would work as long as the header for that column would not change or could be blank:

    Public Sub OnRowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridViewHierachical.RowDataBound

        If e.Row.RowType = DataControlRowType.DataRow Then
            If e.Row.Cells(1).Text = "Delayed" Then
                e.Row.Cells(1).ForeColor = Drawing.Color.Red
                e.Row.Cells(1).Text = "p"  ' <== Wingdings3 character used to produce a down pointing solid triangle
                ' Change the font for column one to wingdings3 ==>  GridViewHierachical.Columns(1).DefaultCellStyle.Font = New Drawing.Font(GridViewHierachical.DefaultCellStyle.Font)
            End If
            If e.Row.Cells(1).Text = "Potential Early" Then
                

Open in new window

0
How can I tell i a text file has tabs in it? I have  vb.net code, but it is not recognizing the tabs, so I am wondering if there are actually tabs in the text file.
0
Hi,

I need to serialize vb.net code to json.

I need the json to look like this:
{
    "KalTid": [
        {
            "AnstNr": "1",
            "Datum": "2014-01-02",
            "RadId": "9b8412eb-77a4-4e0b-853e-fdd78edeac8a",
            "UseTid": true,
            "StartTid": "08:00",
            "SlutTid": "08:00",
            "Timmar": 8,
            "Dagar": 0,
            "TidKod": "SJK",
            "UseBrukare": true,
            "UseResEnhet1": false,
            "UseResEnhet2": false,
            "UseResEnhet3": false,
            "Brukare": "1",
            "ResEnhet1": "",
            "ResEnhet2": "",
            "ResEnhet3": "",
            "Registrerad": true,
            "CalcTyp": "",
            "Source": "PORTAL"
        }
    ]
}

Open in new window


The vb.net classes I'm using are looking like this:
Imports Microsoft.VisualBasic
Imports Newtonsoft.Json

Public Class KalTid
    <JsonProperty("AnstNr")>
    Public Property AnstNr As Long

    <JsonProperty("Datum")>
    Public Property Datum As DateTimeOffset

    <JsonProperty("RadId")>
    Public Property RadId As Guid

    <JsonProperty("UseTid")>
    Public Property UseTid As Boolean

    <JsonProperty("StartTid")>
    Public Property StartTid As String

    <JsonProperty("SlutTid")>
    Public Property SlutTid As String

    <JsonProperty("Timmar")>
    Public Property Timmar As Long

    <JsonProperty("Dagar")>
    Public Property Dagar As Long

    <JsonProperty("TidKod")>
    Public 

Open in new window

1
Hi
in my asp.net web application
what vb.net code would I use to read the e-mail headers and bodies of all unread emails in my inbox
then Mark each e-mail as read
1

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,