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 am trying to hide the chart axes and labels along with the series line color. I just want to show datapoint labels. I have successfully hidden all (by setting color to form's back color). However except for the dashes that appear at axes scale break points. (Please see the below image)

Could someone please help me with hiding these scale break dashes as well? Thanks in advance
Amazon Web Services
LVL 12
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Is it possible to place custom labels on a StripLine? I have a Horizontal stripline and want to place custom labels on some datapoints on this line. Could someone please give me code to do this? Thank in advance
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:
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

How to restrict vertical stripline from x-axis to above x-axis but restrict it from extending below x-axis.

As you can see in the image below the current green vertical line is extending onto the side of negative Y-axis (i.e; below x-axis).

How can I not show the part of green vertical line below x-axis (indicated by red arrow)
Please let me know how to accomplish this. Thanks in advance.
I have a chart currently generated as shown in the image current_chart_mock.png


Is it possible to add labels below  few x-axis values. Please see the below attached image (MAP_mock.png) for what I am trying t ask for.

If possible, could someone please tell me how to accomplish this? Thanks in advance
How can I tell i a text file has tabs in it? I have code, but it is not recognizing the tabs, so I am wondering if there are actually tabs in the text file.

I need to serialize 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 classes I'm using are looking like this:
Imports Microsoft.VisualBasic
Imports Newtonsoft.Json

Public Class KalTid
    Public Property AnstNr As Long

    Public Property Datum As DateTimeOffset

    Public Property RadId As Guid

    Public Property UseTid As Boolean

    Public Property StartTid As String

    Public Property SlutTid As String

    Public Property Timmar As Long

    Public Property Dagar As Long


Open in new window

I am trying to figure out a way to implement on a WCF Service that is version agnostic basically.


public class TestResponse

    public string StudentNo {get; set} 

   pubiic ClassVersion VersionOfClass [get; set;]


[DataContract Name="Class A"]
public class TestClass
      public string Tools {get; set;}

      public string Name {get; set;}


[DataContract Name="Class B"]
public class TestClass
      public string LocationType {get; set;}
      public string Name {get; set;}
      public int NailDepth {get; set;}


Open in new window

Now, I want to be able to use that TestResponse and the ClassVersion object be for the ClassA or ClassB.

Is that possible to be done if is go how? I don't think a Generic would work. Would a typeof?

Any information on this would be greatly appreciated.

I have a datagridview whose styling is kept as follows

    dgvCreatinine.AutoGenerateColumns = False
            dgvCreatinine.AutoSize = False
            dgvCreatinine.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill
            dgvCreatinine.DataSource = dtTemp

It is appearing as shown in the attached image

As you can see the gridview is not resizing to the content along row wise. Could someone tell me how this can be accomplished? Thanks in advance.
I have two series with Legends being added to a chart in

creatinine_series.LegendText = "Creatinine (mg/dL)"
creatinine_series.IsVisibleInLegend = True


urineOutput_series.LegendText = "Urine Output(ml/kg/hr)"
urineOutput_series.IsVisibleInLegend = True

But only urineOutput_series legend shows up. creatinine_series legend doesn't showup. I have no clue why this isn't appearing.

Also I would like to position two legends (If both of them show up). How to position them. Please kindly help me get though this issue.
Learn SQL Server Core 2016
LVL 12
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

in my web application
what 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
My first ASP.NET Web Forms app.  VB.NET code behind (familiar with VB.NET)
I started my app and have it mostly done.   When I started I just made my own GFview.aspx form and put all my code in there.
I see when I created the app, it threw in it's own "Deafult.aspx" file with a bunch of MS links for ASP sites/info.

I want to clear all that mess out and have it be blank and automatically call my GFview.aspx page.

My questions:

If possible, I would like to put the code in the Default.aspx.vb file/code.  What code do I use?
Public Class _Default
    Inherits Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load

        '  ???   <== Here   ?

    End Sub

End Class

Open in new window

I have no idea what the URL would be of the page I want to call.
When I run it in design mode, the URL is this:  "http://localhost:52405/GFview.aspx"

I don't know much about web based functionality.

I guess the goal I am trying to acheive is removing the junk from the Default.aspx page and have my one page be that one that is used.  I hope that makes sense.

I want to copy a file to another location asynchronously.  The following code does not work.  Why?

    Shared Async Function CopyFile(inSourceFile As String, inTargetFile As String) As Task
        Using SourceStream As FileStream = File.Open(inSourceFile, FileMode.Open)
            Using DestinationStream As FileStream = File.Create(inTargetFile)
                Await SourceStream.CopyToAsync(DestinationStream)
            End Using
        End Using
    End Function

Open in new window


We have a simple application that was done by a predecessor. All it does is allows users to enter 'item numbers' and send to print. The item data is saved on a separate excel sheet in the same folder. All dll files, EXE. file and excel file are in the same folder. I've just copied this folder to a new machine trying to replicate the process. I can run the application but when I click send to print button on the application I get below error;

"Unhandled exception has occurred in your application if you click continue the application will..."

"could not load file or assembly microsoft.reportviewer.common version="

I've tried installing the relevant files for above exceptions. However, think this is to do more with the 'Print' button on the application and coding behind it.
Please see attached.

Can someone advise what I need to do to get this to work please?

Thanks in advance.

I have this json request that I want to deserialize to an vb object. The json looks like this:
    "PerReg": [
            "AnstNr": "1",
            "EfNamn": "Ljunggren",
            "FoNamn": "Siv",
            "Adress1": "Föreningsgatan 33",
            "Adress2": "",
            "PostNr": "447 34",
            "PostOrt": "VÅRGÅRDA",
            "LandAdr": "",
            "EpostPriv": "",
            "EpostArb": "",
            "Telefon": "0322-21298",
            "Mobil": "",
            "PersNr": "197901049283",
            "Signatur": "SL",
            "Befattning": "VD",
            "AnstDatum": "2001-09-01",
            "Slutat": false,
            "AvgDatum": "1899-12-30",
            "AnstTom": "1899-12-30",
            "Locked": false,
            "KalSchemaAuto": false,
            "UseOBRegel": false,
            "LockOBRegel": false,
            "OBRegelID": "",
            "UseArbSchema": true,
            "ArbSchema": "1",
            "Avdelning": "10",
            "KalUseAttest": true,
            "PerTyp": "LED",
            "AnstForm": "TV",
            "LoneForm": "MÅN",
            "LSSBerPerStart": "1899-12-30",
            "LSSBerPerInt": "",
            "LSSAnnanArbGiv": false,
            "LSSArbGivNamn": "",
            "LSSArbGivOrgnr": "",
            "UseSysGrad": true,
            "SysGrad": 100,
            "VeckArbTid": 40,
            "HelVeckTid": 40,
            "VeckArbDgr": 5,
            "DagArbTid": 8,

Open in new window

Hi All,

I have a windows form with datagridview that allow user to input at cells.
I want to limit user 999.99

2.   45.22     2 DIGIT NUMBER WITH 2 DECIMAL

Just allow 2 of them.

I try :

  If Not IsNumeric(.CurrentCell.Value) Then
                        .CurrentCell.Value = 0
                        .CurrentCell.Value = Double.Parse(Double.Parse(.CurrentCell.Value).ToString("##0.00"))
                    End If

Open in new window

Is that correct ? Is the any other better way ?

Thank you.
threading.timer does not always start.
i start one threading.timer   that should check after 80 miliseconds if a write to serial port is stuck.  if it is stuck, it purges the comm port and tries to write again.
the problem is that sometimes it works,  and some times the thread does not start.  does anyone know about this behavior ?  and can this be fixed ?
it is running on a win ce  with visual studio  2005.
the write takes 3 miliseconds,  but when it get stuck,  it can take from 10 seconds to 20 seconds,  so checking after 80 miliseconds  seems good.
the code:

               If g.timerStarted = False Then            'starting the timer only one time
                    tTimer = New Threading.Timer(AddressOf tTimerTick, Nothing, CInt(80), CInt(80))
                    g.timerStarted = True
                    tTimer.Change(CInt(80), CInt(80))
                End If
                    doWriteToComm(InSendStr, InDevType, CommResult, RealWriteBytes)      
                tTimerClose()   '  here i change the timer to  tTimer.Change(Timeout.Infinite, Timeout.Infinite)

Hello Again Experts.

I must apologize in advance for my brevity, but I recently injured my hand in the wood shop, and typing is somewhat difficult.

The situation that I am dealing with right now is that I am very frequently experiencing conflict between changes that I make in my Access tables/queries, and keeping my VB.NET Windows Forms app in sync with these changes. For example, if my program is stable with no DB issues, and I decide that I want to add a new field/column to a given table using Access, when I return to my program, it invariably produces errors related to the changes I make.

Today I made a change to an Access Query which is attached to a DataGridView in which I connected a new table to get a related field value. The Query works fine in Access, but now not only does the program fail to compile because of the DGV association, but the Data Source Configuration Wizard shows what before was a View is now a broken Table!

I'm pretty sure that Visual Studio stores a boatload of data pertaining to my database, and that needs to agree with the MDB file, so I just need to know that correct way to make minor changes to my tables and queries. Ultimately what I'm hoping to accomplish is to find a way to have ONE source for my database definitions, and just have a file (or files) store the data.

I realize this is not a lot to go on, but that's all I can offer for the moment.

Many Thanks,
Tony G.Example Error Condition
For a stored query (name is "CREAT_Plot") like the following in Access, what would be the or C# code to call this query and also pass a parameter in place of "[Reports]![TestReport]![Subject]"

SELECT CREAT.Subject, CREAT.CREAT, (IIf([CREAT.TargetDays]=".",".",Val([CREAT.TargetDays])*24)) AS TargetDays
WHERE (((CREAT.Subject)=([Reports]![TestReport]![Subject])))

I have googled about this but could not find an example to call stored query that prompts for input parameters.
Please kindly give me small code snippet to achieve this one.

Thank you
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.

Hi ,

i have working script..
i want to put additional checks in the script to check for files and proceed further.
it should check for files after it checks for source folder.
if all three files available then proceed further to run remaining lines of checking backupfolder.
if even one file is missing or all missing it should write log the missing files and exit

Files names to check-

$logdate=Get-Date -Format ddMMMyyyy_HHmmss
$Logfile = "E:\Logs\FileProcessing_$logdate.txt"

function LogWrite ([string]$logstring)
   Add-content $Logfile -value $logstring

#Zip Files

#check if source exists
if(!(Test-Path $sourcefolder)){
    $msj="The source folder ""$($sourcefolder)"" doesn't exists. Exiting..."
    LogWrite "$( Get-Date -Format "yyyy-MM-dd HH:mm:ss" ) ERROR:`t$msj"
    LogWrite -ForegroundColor Red $msj
    exit -1

#check the target folder or create it
if(!(Test-Path $backupFolder)){
    $msj="The target folder ""$($backupFolder)"" was created"
    LogWrite "$( Get-Date -Format "yyyy-MM-dd HH:mm:ss" ) EXECUTE:`t$msj"
    LogWrite -ForegroundColor Magenta $msj
    New-Item -ItemType Directory -Path $backupFolder | Out-Null
foreach($file in (Get-ChildItem -File $sourcefolder -Filter "*.xml" -Recurse)){
    $date = Get-date -Format "ddMMyyyy_HHmmss"
    $destinationFile = "$($FILE.Directory.FullName)\$($file.Name).zip"
    $MoveFile = …

I'm trying to load multiple results into a reportviewer.  I'm having the user select multiple rows in a datagridview then click a button to load those into a reportviewer form.  It works fine for a single event and associated sub table data.  I envision having the reports sequentially page after page but I'd also be fine if it opened up multiple reportviewer forms ready for printing or saving.  I'd have to limit the total number of openable events I suppose, otherwise a user could open hundreds and that would bog down or fail but that should be easy.  

I played around with a query to capture all the events by serialno using an IN statement in the query builder for the dataset, but I kept getting an error and the reportviewer may not be able to handle it anyways so I thought I would ask before spending too much time on that.

Here's my attempted code that opens only the last selected event in the reportviewer:

       Dim selectedRowCount As Integer = Form1.dgResults.Rows.GetRowCount(DataGridViewElementStates.Selected)
        Dim SerialNo As Integer = Nothing

        For i = 0 To selectedRowCount - 1
            SerialNo = Form1.dgResults.SelectedRows(i).Cells("SerialNo").Value
                Me.IAdapter.Fill(Me.DataSet1.I, SerialNo)
                Me.pAdapter.Fill(Me.DataSet1.p, SerialNo)
                Me.vAdapter.Fill(Me.DataSet1.v, SerialNo)

Open in new window

Hello Experts,
In a web page, when I click on a link, it fails.  Upon doing further research I found that I pass Line 1, but it changes to Line 2 automatically at the Run Time.  Any idea what is going on?  Please try to help.  Thank you very much in advance.

Line 1: DB/IDocument?AutoLogoutOnClose=True&AppName=TKT_DET&TktId=333333
Line 2:;AppName=TKT_DET&TktId=333333

Thank you!
How do I add a autonumber  column to the datatable.
Id ColName
1   abc
2   gfg
3   grg
4 ggg

ID should be autoincrementing column.

I have a form with a Datagridview on it and I need to filter it on a field called BulkSaleNumber. I need help with the statement to filter the Datagridview for all records where the BulkSaleNumber =0. How do I filter the Datagridview so that it will list only those rows where the BulkSaleNumber =0?. Please see my code below.

        Private Sub frmBulkSale_Load(sender As Object, e As EventArgs) Handles MyBase.Load
             'TODO: This line of code loads data into the 'AssetDatabaseDataSet.tblAssetData' table. You can move, or remove it, as needed.
        End Sub

Open in new window

I need help with creating an array from a Select Query of my data table and then reading those array items into a combobox.

My code below just gives me the number of distinct items in the BulkSaleNumber column of my tblAssetData Table, but it doesn't give me the array items so that I can use them to populate my combobox.

Your help will be greatly appreciated in directing me in the right direction in creating an array from a query and then populating a combobox with the array  items.

        Dim myArray(0) As String
        Dim i As Integer
        Dim myReader As OleDbDataReader

        cmd.CommandType = CommandType.Text
        cmd.CommandText = "SELECT DISTINCT BulkSaleNumber FROM tblAssetData"
        myReader = cmd.ExecuteReader()
        Do While myReader.Read()
            myArray(i) = myReader!BulkSaleNumber
            ReDim Preserve myArray(UBound(myArray) + 1)
            i += 1

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,