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

Hi, See below my code, No output, any idea?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Configuration;
using System.Text.RegularExpressions;
namespace TestPush
    public class Test

        public string TestName { get; set; }

        private SqlConnection con;
        private dbConnect dbconnect;



        public List<Test> Readytosend()
            List<Test> lstready = new List<Test>();
            con = new SqlConnection();
            con.ConnectionString = dbconnect.Connectionname;
            SqlCommand cmdReadysend = con.CreateCommand();
            cmdReadysend.CommandText = "TestSp"; // no parameters,Only select statement
            cmdReadysend.CommandType = CommandType.StoredProcedure;
            SqlDataReader rdrReadytoSend = cmdReadysend.ExecuteReader();
            while (rdrReadytoSend.Read())


              new Test
                  TestName  = rdrReadytoSend["TestName"].ToString()





Open in new window


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

I have a requirement to have users either enter data into cells in a gridview (three textboxes).

Initially, the checkbox and cells are blank by default.

If user enters data into the cells, then the checkbox does not have to be checked.

If however, user does not want to enter data into the cells, then the user must check the checkbox which automatically disables the cells and allows user to submit data.

So far, the code below is not working.

Any ideas what I am doing wrong?

     Protected Sub Grid1CheckChanged(ByVal sender As Object, ByVal e As EventArgs)
        'Dim hasBlank As Boolean = False
        For Each row As GridViewRow In Gridview1.Rows
            Dim ename As TextBox = TryCast(row.FindControl("txtsourcename"), TextBox)
            Dim empaddress As TextBox = TryCast(row.FindControl("txtsourceaddress"), TextBox)
            Dim empincomesrc As TextBox = TryCast(row.FindControl("txtsourceincome"), TextBox)
            Dim sourceCheck As CheckBox = DirectCast(Gridview1.FindControl("grid1Details"), CheckBox)
            If Not sourceCheck.Checked Then
                'hasBlank = True
                ename.Enabled = True
                empaddress.Enabled = True
                empincomesrc.Enabled = True
            ElseIf Not sourceCheck.Checked And ename.Text Is Nothing And empaddress.Text Is Nothing And empincomesrc.Text Is Nothing Then
                lblStatus.Text = "Please either fill out the textboxes or check the checkbox."

Open in new window

Hello Experts!

So I have a problem, I can't seem to figure out.
I need a connection string to allow the program to connect to the SQL Server using an Active Directory Account.

However, the Active Directory account is different from the users logged in account, because we don't want to allow the user to have access to SQL just the can I configure the Connection String to use the programs AD account and not the users AD Account?

I'm getting following Error message when i trying to create the following assembly

Msg 6544, Level 16, State 1, Line 1
CREATE ASSEMBLY for assembly 'System.ServiceModel' failed because assembly 'microsoft.visualbasic.activities.compiler' is malformed or not a pure .NET assembly.
Unverifiable PE Header/native stub.

Sql server version is :
Product : Microsoft SQL Server Developer (64-bit)
Microsoft SQL Server 2016 (SP1-GDR) (KB4019089) - 13.0.4206.0 (X64)   Jul  6 2017 07:55:03   Copyright (c) Microsoft Corporation  Developer Edition (64-bit) on Windows 10 Home 6.3 <X64> (Build 15063: )
System.BadImageFormatException occurred
  Message=Could not load file or assembly 'Interop.MakeCardp, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
  Source=<Cannot evaluate the exception source>
<Cannot evaluate the exception stack trace>

I've  VB.NET application  that uses a Vb6 activex in VS2010 without problems. I've moved that app to VS2017 (idem framework 3.5,  platform and target cpu x86) and now I get the error above.

any suggestions?
How do I format Now() to reflect this exact formatting?

I've got some code which populates events over time on an excel sheet. At the end of the process my program creates a chart using the following code

Imports Excel = Microsoft.Office.Interop.Excel

 Dim xlApp As Excel.Application = New Microsoft.Office.Interop.Excel.Application()
    Dim xlWorkBook As Excel.Workbook = Nothing
    Dim xlWorkbooks As Excel.Workbooks = Nothing
    Dim xlWorkSheet As Excel.Worksheet = Nothing

    Dim chartPage As Excel.Chart
    Dim xlCharts As Excel.ChartObjects
    Dim myChart As Excel.ChartObject
    Dim chartRange As Excel.Range

xlCharts = xlWorkSheet.ChartObjects
        myChart = xlCharts.Add(10, 80, 900, 500)
        chartPage = myChart.Chart
        chartRange = xlWorkSheet.Range("B1", "d100")
        chartPage.ChartType = Excel.XlChartType.xlBarStacked

How do I, in code do the simple operation of twitching "Axis Type" from automatic to "Date axis". This is usually found by clicking the vertical axis of a chart, format axis, axis options - date axis.

Is there a resource to find these commands?

Best regards,

I can't seem to get the autofill working on my forms for iPhone etc. (.Net 4.0 Web Site)

I've accessed numerous things online, done it and just never seems to work.

Example...  I tried following instructions Here and I have autofill options in Safari turned on as well.

(Two of my controls...)
<label for="nameoncard">Name on Card</label><br />
<input type="text" id="inpcardname" runat="server" name="nameoncard" class="field" placeholder="Cardholders Name" autocomplete="nameoncard"  />

No prompt for autofill when I go to the page from my iPhone.
Is there a way to zoom the size of a MDI Child Form without setting WindowState to 'Maximized'?
I am trying to design a similar winform to the Office>>Options layout screen.

I believe the main control to group the different option is a splitter control - Is that correct?

Also the options on the far left side seems to be buttons. I believe I am correct however how does the when a user clicks on the suppose button does it change the Panel on the opposite side along with each button having unique panel changes.

I have attached a word example and my current setup.
Concerto Cloud for Software Providers & ISVs
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Hello to all VB Guru's

I'm trying to make a vb script (.vbs) subroutine that will:

Continually check if a process (.exe) is running
Once it's done running (finished), then launch another program (.exe).
Everything I've tried to far, doesn't work.

Really appreacate all your assistance!

I upgraded my VS2005 to VS2013 and I'm now unable to access my Database schema (.XSD File).
When I double click it I get the following Screen do I fix this?

I'm looking into Visual Studio Community to get a start in Visual Studio programming (and to see if I like it). I believe I can create a standalone executable app in this free version. Am I correct?
My app will require database tables. Does Visual Studio come with a database server? What is the default in Visual Studio?
Do I need to obtain a separate data server like MySQL or MariaDB or something?
I am looking to create a simple system that starts and stops a stopwatch on a sound. The sound would be always be the same and sent through the line in on a laptop.

Ideally doing this in Excel, but could do it in too.

I originally thought this would be fairly simple, but on doing some research I havent found any examples.
If I use the following code it will hide the tab or display the tab, the only problem is that when it displays the tab no control are present inside the tab. Do the controls need to be added dynamically after the Tabpages.add ? or am I missing something?

 If _masterGlobalParameters.masterGlobal.MasterShowDSG_SGProbeTab = True Then
            End If

Open in new window

The following below is is using the file dialog control in vb. I am wanting to know how to automate a file write behind the scenes.

Const FileDirectory as string
Const File Name as string.

 If Me.SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
                Dim stream As FileStream = New FileStream(Me.SaveFileDialog1.FileName, FileMode.Create)
                Dim streamwriter As New StreamWriter(stream)
                SaveAs = Me.SaveFileDialog1.FileName
                'Add in Saved file header Information first
                streamwriter.WriteLine("Collected Data from G-WHIZ Distance Curve")
                streamwriter.WriteLine("Rate:  " & RateVar)
                streamwriter.WriteLine("Run Distance:  " & DistanceVar)
                For intloop = 0 To DisData.Count - 1
                    If value = 100 Then
                        value = value + 0.5
                        PrgGraphBar.Value = value
                    End If
                PrgGraphBar.Value = 0
            End If

Open in new window

I have several ComboBoxes in my program, and the ones that have text already in the box end up highlighted.  This is true even looking at the form in Visual Studio (see attached).  Is there a way to keep the text from being highlighted?  The text in these boxes are highlighted when the program is launched.
I have a script that is popping a window (uglipop) from vb code

ScriptManager.RegisterClientScriptBlock(Me, Me.GetType(), "script", "$(document).ready(function () { custom1(); });", True)

On close of that window how do I reload the current page?

I would like some advice on creating a windows application that includes Maps where users can search for locations and generate directions between locations.

Currently I have created the app with a web browser that points to Google maps where the user can then enter the information required. However, this also includes all the extras that comes with the website, which I don't really want.

The next approach could be to add a mapping API, preferably Google but I need it to be free... Is this possible? If so how should I start.

The app that I am creating is for internal business use, for basically locking down a PC so the users can only use the mapping website.

Thanks, Greg
Free Tool: IP Lookup
LVL 11
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Hi, I've just finished my game except for this part.

I need to mousehover over any balloon picturebox in my forms to then pop them and animate, but i can do that part myself

I don't know how to make a hover event / function with the way i've approached this



Imports System.Drawing
Imports System.Windows.Forms
Public Class stage1
    Dim holdbox() As PictureBox

    Dim score As Integer = 0

    Private Sub stage1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub
    Public Sub tmrSpawn_Tick(sender As Object, e As EventArgs) Handles tmrSpawn.Tick
        Dim holdbox(3) As PictureBox
        For i = 1 To 3
            holdbox(i) = New PictureBox
            holdbox(i).Name = "balloon" + Str(i)
            holdbox(i).Image = Image.FromFile("C:\Users\Reece\Desktop\School Work Year 12\VB Projects\PopGame.vb\balloon.png")
            holdbox(i).BackColor = Color.Transparent
            holdbox(i).Location = New Point(((400 - 1 + 1) * Rnd() + 1), 0)
            holdbox(i).Size = New Size(70, 30)
            holdbox(i).Visible = True
            holdbox(i).SizeMode = PictureBoxSizeMode.StretchImage
    End Sub

    Private Sub tmrBegin_Tick(sender As Object, e As EventArgs) Handles tmrBegin.Tick
        tmrSpawn.Enabled = True
    End Sub

    Public Sub …
I have a web page with code behind. The page contains several combo boxes, and goes through some validation rules after user clicks the 'submit' button. If a validation error is found, a hidden <div> is displayed on the web page with the errors. The page scrolls up to the validation <div> using some javascript; see below which is executed from the code behind. For some reason, the javascript is causing the combo boxes and text input fields to be frozen. If the page is refreshed, the user can then modify or update the input controls. Anyone have an idea what is going on?


        Dim script As String = "document.getElementById('ValidationResults').scrollIntoView(true);"
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "key", script, True)
I have a web page that is utilizing as the code behind. I have a form that contains many input controls. After user clicks the submit button, the code behind reviews input and validates all fields are populated. If a validation error is detected, a hidden <div> is made visible with a list of errors for the user to correct. For some reason, all of the drop downs, text fields, etc cannot be changed or modified. Not sure why, it's like everything is frozen. However, there is a help link...when clicked, a window is opened with helper information. After user clicks to close the helper window, all of the controls are usable again. I'm thinking I need to refresh the page when an error is detected. Anyone have some guidance?
It really is a simple question yet finding so much trouble with Google finding how to do it. After the where clause I want to return the results from my strongly typed dataset table with a parameter passed from a parameter with and how to call it. If you can assist I would appreciate it.

Bolded is where I think it should go. But I clearly don't know how to say it. "test" would be something like
"row.Item(columnname) IsNot DBNull.Value AndAlso row.Item(columnname) = filter AndAlso row.TT_Rec_ID = Template_ID" just for example. But the way I see it we should be able to pass anything through that is LINQ compatible.

Function Global_Table_Query([b]ByVal test As Predicate(Of ds2.JOINEDDATADataTable[/b])) As DataTable
        ErrorMessage = ""

        Dim dt As New DataTable
        Dim Is_Good As Byte = 1
               Dim thread As New Task(

          Dim lowNums = From row In Global_Table
                        [b]Where test
[/b]                        Select row

          dt = lowNums.CopyToDataTable
                    Return dt
      Catch ex As Exception
          ErrorMessage = ex.Message
          Return Nothing

      End Try
  End Function

        Dim tasks() = {thread}
        Array.ForEach(tasks, Sub(tx) tx.Start())

        For Each tsk In tasks

            Select Case True

                Case tsk.IsCanceled
                    Is_Good = 1


Open in new window

I am writing to a .csv file using .WriteLine(sometext) and find that the first row appears to have hidden characters prefixed to it.
When inspecting the .csv in Excel or by notepad the first letter T is ok, however I believe there are hidden characters before the T. Inspecting the file with a HEX reader there is definitely some unprintable characters at that position.
This is the first line of the file.

The actual text is "T,9999999, ,Company Name,X,D," +
                                           Strings.Left(strDateEnded, 2) + Strings.Mid(strDateEnded, 4, 2).PadLeft(2, "0"c) + Strings.Right(strDateEnded, 2) + "," +
                                           Strings.Mid(strDateStarted, 4, 2).PadLeft(2, "0"c) & Strings.Right(strDateStarted, 2) & ",xxx01, ,"
How to display the session remaining time (in MM:SS) on a web page

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,