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

Hi,

I would like to get help with converting from vb.net to json. I need to have classes and conversion to be in this format once it's been serialized:
{
  "Employee": {
    "EmployeeId": "9978",
    "PersonalIdentityNumber": "19730222-9989",
    "FirstName": "Karin",
    "LastName": "Brovall",
    "FullName": "Karin Brovall",
    "Address1": "",
    "Address2": "Båtsmansvägen 7",
    "PostCode": "441 50",
    "City": "ALINGSÅS",
    "Country": "",
    "Phone1": "0322-36844",
    "Phone2": "",
    "Email": "",
    "EmploymentDate": "1997-10-01",
    "EmploymentForm": "TV",
    "SalaryForm": "TIM",
    "JobTitle": "Försäljning",
    "PersonelType": "ARB",
    "ScheduleId": "HEL",
    "ForaType": "-",
    "MonthlySalary": 0,
    "HourlyPay": 125,
    "TaxAllowance": "TMP",
    "TaxTable": 34,
    "TaxColumn": 1,
    "NonRecurringTax": 30,
    "Inactive": false,
    "ClearingNo": "", 
    "BankAccountNo": ""
  }
}

Open in new window


For this reason I used json utils to convert to classes and got this result:
    Public Class Employee
        Public Property EmployeeId As String
        Public Property PersonalIdentityNumber As String
        Public Property FirstName As String
        Public Property LastName As String
        Public Property FullName As String
        Public Property Address1 As String
        Public Property Address2 As String
        Public Property PostCode As String
        Public Property City As String
        Public Property Country As String
   

Open in new window

0
Cloud Class® Course: Ruby Fundamentals
LVL 12
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

I am converting my VB6 desktop app to VB.NET and ASP.NET so that I can "webify" the application I have.  What is the best way to begin learning?  I downloaded and installed the Community Edition of Visual Studio.  Should I start googling ASP.NET first or VB.NET first?  How will this actually play out?  Will I end up having to learn both at the same time since they are tied?  What exactly is the relationship between the two?

Also will I need to know HTML and any other languages?  At the end of the day, I am only looking to convert about 6 screens in my VB6 app to .NET so that it can be accessed from more users and even Mac users.

Thanks
0
Hi experts,

I'm using the Telerik UI for ASP.NET AJAX RadWindow.
https://demos.telerik.com/aspnet-ajax/window/examples/overview/defaultcs.aspx

I'm using ASP.NET and VB.

I saw this example here for passing a parameter from the Main page to the RadWindow:

Using RadWindow as a Dialog
https://docs.telerik.com/devtools/aspnet-ajax/controls/window/how-to/using-radwindow-as-a-dialog

I recreated this example and it works fine.

This is the working code:

RadWindow1_MainPage.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="RadWindow1_MainPage.aspx.vb" Inherits="RadWindow1_MainPage" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">

        // https://docs.telerik.com/devtools/aspnet-ajax/controls/window/how-to/using-radwindow-as-a-dialog

        // The OnClientShow event handler sets the argument to the dialog being opened
        function clientShow(sender, eventArgs) {
            // When the showRadWindow1 button is clicked the value from the textbox is pass to RadWindow1 as an argument
            var txtInput = document.getElementById("txtInput");
            sender.argument = txtInput.value;
        }
        // The OnClientClose event handler receives the result of the dialog and responds
        function clientClose(sender, args) {
        

Open in new window

0
Im getting started to learn VB.NET and ASP.  I am coming from a background with some experience in VB6.  

What software tools do I need in order to develop a webpage with VB.NET and ASP?  Do I need a specific web server from Microsoft?  If so, what version?  Do I need Visual Studio?  If so, what version.  What is needed to begin setting up ASP?  Is that automatically built-in to the web server?

Also, what is the difference between ASP and ASP.net, if any?

Thanks
0
I have been programming in VB6 for years.  I have a desire to begin programming in VB.NET.  With .NET would I be able to make my application usuable from a webpage?  The current program I have is written in VB6 and can only be used from a windows desktop.  Here is one of my forms below for registering individuals in VB6.  What is the fastest way to begin learning how to convert this code into VB.NET?  If I get the .NET software does it have the ability to convert and if it does, how well does it perform?

Thanks for answering my preliminary questions as I know I have a road ahead.

Set conn = New ADODB.Connection
Set rec = New ADODB.Recordset
conn.Open "Provider=sqloledb;Data Source=" & ConnectionIP & ",1433;Network Library=DBMSSOCN;Initial Catalog= " & CAPDB & "; User ID=xx;Password=xxxx"

   ' If Not AsNumbers(Me.Text19.Text) Then
   '     MsgBox "Please enter a valid address", vbOKOnly
   '     Exit Sub
   ' End If


If DTPicker1 = ServerTime Then
    MsgBox "You Need to enter a BirthDate", vbOKOnly
    Exit Sub
End If

If Val(Text6) <= 0 Then
    MsgBox "Your Birthdate is Incorrect.  Please adjust.", vbOKOnly
    Exit Sub
End If

If Text2 = "" Then
    MsgBox "You Need to enter a Last Name", vbOKOnly
    Exit Sub
End If

If Text3 = "" Then
    MsgBox "You Need to enter an First Name", vbOKOnly
    Exit Sub
End If

If Combo12 = "CCASP" Or Combo12 = "Scouting Network" Then
    If Combo6 = "" Then
    MsgBox "You Need to enter a Sub Group", vbOKOnly
    Exit Sub
  

Open in new window

0
Hello,
I have code which saves the excel sheet to .csv.
It works well with 1 sheet but how do  address multiple sheets and save the seperate csv for every sheet.
Please find the code for 1  sheet below:

  Private Sub SurroundingSub()
        Dim officeType As Type = Type.GetTypeFromProgID("Excel.Application")

        If officeType Is Nothing Then
        Else
            Dim app As Microsoft.Office.Interop.Excel.Application = New Microsoft.Office.Interop.Excel.Application()
            app.DisplayAlerts = False
            Dim excelWorkbook As Microsoft.Office.Interop.Excel.Workbook = app.Workbooks.Open("C:\test.xlsx")
            Dim newFileName As String = System.IO.Directory.GetCurrentDirectory() & "\DataMigration.csv"
            excelWorkbook.SaveAs(newFileName, Microsoft.Office.Interop.Excel.XlFileFormat.xlCSV)
            excelWorkbook.Close()
            app.Quit()
        End If
    End Sub

Open in new window

0
Hi,
I am using vb.net desktop version, need to convert a excel sheet to csv.
Need to calculate the used range of excel and convert it into comma seperated csv.

***Please note speed is an issue here, if you suggest any code with high performance it will be appreciated the most.
Thanks
0
Hi All,

I have datetime data : 2016-04-01 14:33:43.070

Using DateTime type I get : #4/1/2016 02:33:43 PM#

How could I save to variable at VB.NET ?
How could I pass it as parameter to SP ?

I need data to milisecs.

Thank you.
0
I'm using Managed EWS to Process email messages. If there is a error in the Processing I grab the Text Body of the Message, create a new Text Message, add my Errors to it and then append the Original Body Text.

I'm setting the PropertySet - view.PropertySet.RequestedBodyType = BodyType.Text
I'm passing PropertySet view to both FindItems and to Item.load

The email comes back as just one long string of text, the CR/LF Formatting is lost. Even the ones I'm adding in. I can Look at the bodyText in the Watch List and I can see the CR/LF, though when I get the email its jsut one long text string.
The Same code worked fine in the Non-Managed EWS.

[...snip...]
            Dim inboxItems As FindItemsResults(Of Item)
            ' Create a view with a page size of itemPageSize.
            Dim view As New ItemView(emailsToProcess)
            view.PageSize = emailsToProcess

            'Indicate that the base property will be the item identifier
            view.PropertySet = (New PropertySet(BasePropertySet.FirstClassProperties))
            view.PropertySet.RequestedBodyType = BodyType.Text

            'ONly Items in the Current folder that are not deleted.
            view.Traversal = ItemTraversal.Shallow

            ' Send the request to search the Inbox and get the results.
            inboxItems = sharedMailbox.GetEmails(WellKnownFolderName.Inbox, view)

           ' Process each item.
            For Each item As Item In inboxItems.Items
                Dim

Open in new window

0
what could be causing the logfile.txt to clear out after x amount of entries?
My code writes to a log file and it works fine but after a few entries all of the sudden the txt file is blank. Any Idea what could be going on?
Here is my code
 Using objfile As StreamWriter = File.AppendText("C:\vbcode\logfile.txt")
                objfile.WriteLine(ComboBox1.SelectedItem.ToString() & " Reprinted #:" & TextBox1.Text.ToString & vbTab & Today())
            End Using

Open in new window

0
Cloud Class® Course: Certified Penetration Testing
LVL 12
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Hi

In my ASP.net web app I want a user to be able to download an Excel file that I have in my resources.
What VB.net code would I use behind a  button click for this
The Excel file is called Steel.xls
It is a 97 to 2000 Workbook
0
I'm using ASP.NET Web Forms and VB.
I'm using Sql Server.
I'm using the DataGrid control. Yes I know the newer grid is GridView, but I need to do this with DataGrid.

I'm using the Employees table from the Northwind database.

Here is the script to create the table:

USE [Northwind]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Employees](
	[EmployeeID] [int] IDENTITY(1,1) NOT NULL,
	[LastName] [nvarchar](20) NOT NULL,
	[FirstName] [nvarchar](10) NOT NULL,
	[Title] [nvarchar](30) NULL,
	[TitleOfCourtesy] [nvarchar](25) NULL,
	[BirthDate] [datetime] NULL,
	[HireDate] [datetime] NULL,
	[Address] [nvarchar](60) NULL,
	[City] [nvarchar](15) NULL,
	[Region] [nvarchar](15) NULL,
	[PostalCode] [nvarchar](10) NULL,
	[Country] [nvarchar](15) NULL,
 CONSTRAINT [PK_Employees] PRIMARY KEY CLUSTERED 
(
	[EmployeeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
SET IDENTITY_INSERT [dbo].[Employees] ON 

INSERT [dbo].[Employees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City], [Region], [PostalCode], [Country]) VALUES (1, N'Davolio', N'Nancy', N'Sales Representative', N'Ms.', CAST(N'1948-12-08T00:00:00.000' AS DateTime), CAST(N'1992-05-01T00:00:00.000' AS DateTime), N'507 - 20th Ave. E.
Apt. 2A', N'Seattle', N'WA', N'98122', N'USA')
INSERT [dbo].[Employees] ([EmployeeID], 

Open in new window

0
When I try to open a project in Visual Studio 2017 I get the following error.

C:\Users\rgtur\Desktop\Tarabu\Tarabu\Tarabu.vbproj : error  : The project file could not be loaded. Data at the root level is invalid. Line 1, position 1.  C:\Users\rgtur\Desktop\Tarabu\Tarabu\Tarabu.vbproj

How do I fix this?
0
vb.net 2010

Visual Basic form

It has been awhile(in vb.net) but, I put a simple Textbox(Common Control) on a form.

When i run the application, I can't click in the Textbox ?  
It is Enabled - ReadOnly  =  False
It is Unbound Textbox


Thanks
fordraiders
0
Hello,
How to export a image column of sql server to PDF/word  in vb.net.
I am using visual studio 2017 windows version.

Thanks
0
I saw this example:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/53983755-bcdd-4d35-b307-08b370e42f81/copy-datagrid-to-datatable?forum=csharpgeneral

which had this C# code.

DataSet dsDG = new DataSet();
DataTable dt = new DataTable();
//first cast the DataSource into a DataSet
dsDG = (DataSet)MyDataGrid.DataSource;
//then pull the DataTable out of the Dataset
dt = dsDG.Tables[0];


What's the equivalent if these 4 lines in VB?
0
Hi All,
I would like if someone could explain to me how to use a class to store variable info, and be able to use that info in different forms.
Public Class clRUN_SUBSCRIPTION_VARS

    'Data
    Public ITEM_KEY As Int32
    Public sItem_NAME As String
    Public sITEM_NAME_DESC As String

    Public Sub New()
        ITEM_KEY = Nothing
        sItem_NAME = Nothing
        sITEM_NAME_DESC = Nothing
    End Sub

Open in new window



Procedure1:
DIM rsv as new clRUN_SUBSCRIPTION_VARS
Procedure_2(rsv_t as clRUN_SUBSCRIPTION_VARS)

Procedure2:
I passed in rsv instance into procedure2 and assigned the values from a database query

Then pack in Procedure1 I process the data and send the rsv instance to various procedures and functions.

This all works fine.  My problem is passing this RSV class instance to another form for processing.
I've managed to do it by setting the Class variables as Shared; but don't think that is what I want as it could be confused with other calls to the class to create a different instance of the class.

Hope I'm explain this correctly.
thanks,
John.
0
Hi,
How can i get the foldername from a path.

Cheers
0
Excel VSTO Ribbon add-in... MessageBox not showing in excel
        Try
            ZipFile.ExtractToDirectory(excelA.ActiveWorkbook.FullName, "C:\exp")
        Catch ex As Exception
            MessageBox.show(ex.InnerException.ToString)
        End Try

Open in new window

0
Cloud Class® Course: C++ 11 Fundamentals
LVL 12
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

I have a grid view on a master page that is in an update panel which is in a panel and this is used with a popup extender.  The gridview works ok, but the 'Done' button returns an error when trying to close the popup after making changes to the Grid view with the row commands.  This has to do with the post back, but I don't know how to fix.  The 'Done' button works fine if I don't make any changes to the grid view.  I have left the page EventCausesValidation=true by default.

This is the error:  
JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

Please help.  Thanks

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        
        If IsPostBack = True Then
            
        Else
            

            CoreQuestDataSource.DataBind()
            CoreQuestGrdVw.DataBind()

           
        End If


    End Sub

Open in new window


Protected Sub CoreQuestGrdVw_RowCommand(ByVal sender As 

Open in new window

0
Hello,
How to delete empty rows in a mail merge Word from vb.net desktop app.
Cheers

I have code for removing fields :

  Sub RemoveBlankFields(ByVal doc As Object, ByVal StrToReplace As String)

        Dim wdApp As Object 'Word.Application
        Dim Unit1 As Microsoft.Office.Interop.Word.WdUnits = Microsoft.Office.Interop.Word.WdUnits.wdLine

        'Dim doc As Word.Document
        'Set wdApp = doc.Application
        wdApp = doc.Application
        doc.Range.Select()
        wdApp.Selection.Find.Text = StrToReplace
        Dim wdCharacter As Object = Unit1.wdCharacter
        Dim wdExtend As Object = Word.WdMovementType.wdExtend


        Do While wdApp.Selection.Find.Execute(FindText:=StrToReplace, Forward:=True,
                    Format:=True) = True
            With wdApp.Selection
                ' .Expand(Unit1)
                ' .Delete
                '.Typebackspace
                .HomeKey(Unit1, missing)
                .MoveDown(Unit1, 1, wdExtend)
                .Delete(wdCharacter, missing)
                .TypeBackspace
            End With
        Loop
    End Sub

Open in new window

0
I want to read and write text from TextBox1.text to my resources "BINDB" I already imported the BINDB.text to resources. I was able to load the items from the text file imported to the resources but I can't save or write to it. Please help me with this code. Im using VS2017 Community.



Thanks in advace.
0
Public Class Form2
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        TextBox2.MaxLength = 8
        TextBox2.Text = TextBox1.Text
    End Sub
End Class

Open in new window


Hi, I want to copy textbox1 to textbox2 but limit it's maxlength to 8 characters only
Note that textbox1.text may contain 9 characters and above

EX:
ABCDEFGHI should be ABCDEFGH only
ABCDEFGHIJKL should be ABCDEFGH only
ABCDEFGHIJKLMN should be ABCDEFGH only
ABCDEFGHIJKLMN123 should be ABCDEFGH only
ABCDEFGHIJKLMN123456 should be ABCDEFGH only



Thank you
0
Hi Experts. I need  code examples for paypals DoCapture  API.  Asp.net c# or vb. I tried to use the links on github to see the examples there but they are blocked by the company I am contracting for.

Specifically this is what I need: The request and response examples


Thanks
Bill
0
Hi

I want to record the row indexes of my ASP.net GridView when a TextBox template field is changed.
The template field's markup is shown below and the VB.net code that I am using to store the row indexes
in the variable oMyStockLinesChanged is shown further on. As you can say I have not set AutoPoastBack to true.
Is this the right way to do this?

 
                <asp:TemplateField HeaderText="Qty Available" SortExpression="Quantity" >
                       <ItemTemplate>
                       <asp:TextBox  ID="txtQty" OnTextChanged="Text_Changed_in_txtQty_Template" ToolTip="Change the quantity here and click the 'Update' button" runat="server" Text='<%# Bind("Qty")%>' Width="80"  ></asp:TextBox>
                       </ItemTemplate> 
                </asp:TemplateField>

Open in new window


    Protected Sub Text_Changed_in_txtQty_Template(ByVal sender As Object, ByVal e As EventArgs)

        Try
            Dim row As GridViewRow = (CType((CType(sender, TextBox)).NamingContainer, GridViewRow))
            Dim oRowIndex As Integer = row.RowIndex

            Dim oThis As TextBox = CType(row.FindControl("txtQty"), TextBox)
            Dim oText As String = oThis.Text

            If IsNumeric(oText) = True Then
                If CDec(oText) > 0 Then
                    If oMyStockLinesChanged = "" Then
                        oMyStockLinesChanged = oRowIndex.ToString
                    Else
                        oMyStockLinesChanged = oMyStockLinesChanged & "," & oRowIndex.ToString
                    End If
       
                End If
            End If

        Catch ex As Exception
            Response.Write(ex.Message & " asx33")
        End Try

    End Sub

Open in new window

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,