Visual Basic.NET

94K

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

I want to look at the DataGridView whether I use immediate window or the watch.  The problem is if I do something as simple as dgv.Rows.Count I get &H2 instead of a number.  How do you change this so you can see a numeric value and NOT Hex?

DataGridView
0
Hi

      I am trying to build an html button for an email where the button is wrapped in a table cell using the following code. It isn't working properly as shown in the attached image

      Dim oLinkAccept As String = "http://SteelYard.azurewebsites.net/offers_to_me?oOfferID=" & oNewOfferID & "&oOfferAcceptDecline=Accept"

            oHBody = oHBody & TableCellWrapper("<a href=" & oLinkAccept & " style='padding: 8px 12px; border: 1px solid #006400;border-radius: 2px;font-family: Helvetica, Arial, sans - serif;font-size:   14px; color: #006400;text-decoration: none;font-weight:bold;display: inline-block;' >ACCEPT</a>")

    Function TableCellWrapper(ByVal X As String) As String

        Dim S As String

        S = "<table width = '100%' cellspacing='0' cellpadding='0'>"
        S &= S & "<tr>"
        S &= S & "<td>"
        S &= S & "<table cellspacing = '0' cellpadding='0'>"
        S &= S & "<tr>"
        S &= S & "<td style = 'border-radius: 2px;' bgcolor='#ED2939'>"
        '<a  Class=”link” href="https://www.copernica.com" target="_blank">
        'Click            
        '</a>
        S &= S & X
        S &= S & "</td>"
        S &= S & "</tr>"
        S &= S & "</table>"
        S &= S & "</td>"
        S &= S & "</tr>"
        S &= S & "</table>"



        TableCellWrapper = S

    End Function

Image1.jpg
0
Hi

I am building the following clickable button link and it looks good and works well in most emailing systems except gmail where it just appears as a normal hyperlink with no border. Why would that be?


            Dim oLinkAccept As String = "http://SteelYard.azurewebsites.net/offers_by_me?oOfferID=" & oOfferID & "&oCounterofferAcceptDecline=Accept"

            oHBody = oHBody & "<a href=" & oLinkAccept & " style='padding: 8px 12px; border: 1px solid #006400;border-radius: 2px;font-family: Helvetica, Arial, sans - serif;font-size:   14px; color: #006400;text-decoration: none;font-weight:bold;display: inline-block;' >ACCEPT</a>"
0
I am trying to parse a return value of the date.now

I have the following:

'On a button control I have the following

Dim date1 as Date = Date.now

'I would like to parse the returned value # 9/5/2019 01:27:04 PM#

Open in new window


The format I am trying to get is the following
<min,hour,date,weekday,month,year>

So the returned value above would look like:

<27,01,05,4,9,2019>

Any help would be amazing.
0
Hi.  I am using the following hyperlink in the html of an email. I now want to include a text box
 in the email body too. I want the user to enter a value in the text box so that when my hyperlink is clicked it uses the value in the text box


  Dim oLinkAccept As String = "http://xxxx.azurewebsites.net/offers_to_me?oOfferID=" & oNewOfferID & "&oOfferAcceptDecline=Accept"

       oHBody = oHBody & "<a href=" & oLinkAccept & ">ACCEPT</a>"
0
In VB.net, Suppose I am accepting user input as a string. I need to check for a value of Zero. However it is possible that someone could enter "000000", or "000",
Which I would consider as valid because when converted to an integer, they are equivalent. 0 = 0

Without converting this input value "000000" to an integer, what would be a good way to check if the entire string contains only the character(s) "0"
0
I am working on a Windows Form Application

I have a text box control which has a LostFocus event. Is it possible to determine which key was pressed inside of this event? As you know I can determine the keypress in the _KeyPress event for the control, however it would be nice to be able to determine which key was pressed when inside of the LostFocus event.

Ex:
Private Sub TextBox1_LostFocus(sender As Object, e As System.Windows.Forms.PreviewKeyDownEventArgs)


End Sub
0
Hi.  I am using the following code to catch errors in the Xero API.The following has the ValidationException, but there are other exceptions like .APIException and .BadRequestException
How do I get the information on Exceptions if there are more than one of these types of Exception?      

Catch ex As Xero.Api.Infrastructure.Exceptions.ValidationException

            For Each v In ex.ValidationErrors
                System.Diagnostics.Debug.WriteLine(v.Message)
                oValidationErrors = oValidationErrors & " " & v.Message
            Next
            Response.Write("Error Line Details " & oValidationErrors)

        End Try
0
Hi

I have a local SQL Server database that I connect to using the following connection string in VB.net
For some reason I suddenly can't connect. Nothing has changed about the database
Server=DESKTOP-CVD5K6J;Database=VBDataSQL;User ID=VBUser;Password=4vbu;Integrated Security=true
0
Hello,
How to make a tabcontrol , tabheaders invisible.
I am using vb.net .

Thanks
0
Hello,

When trying to reference Form1 from From2 in a project compiled as class library (Testlibrary), I receive the following error message:
"Reference to a non-shared member requires an object reference"
 I tried using the name of the library and was able to link it to Form1 but the C1TrueDBGrid control (C1Screen3) is still given the same error message.

How do I fix this issue?

For Each Srow In Testlibrary.Form1.C1Screen3.SelectedRows *****Error Line***
            If vc1 > 0 Then
                '  xyzwc = xyzwc & "OR NSN LIKE " & "'%" & Me.C1Screen3.Columns("NSN").CellText(Srow) & "%'"
                xyzwc = xyzwc & "," & "'" & Form1.C1Screen3.Columns("NSN").CellText(Srow) & "'"
            Else
                ' xyzwc = "NSN LIKE '%" & Me.C1Screen3.Columns("NSN").CellText(Srow) & "%'"
                xyzwc = "'" & Form1.C1Screen3.Columns("NSN").CellText(Srow) & "'"
            End If
            vc1 = vc1 + 1
        Next

Kind regards,

Victor
0
I need to determine when the application user tabs out of a specific text box control on my  VB.net Windows form.
I am using all of the below events to try and capture when focus leaves the text box (Either by tabbing or a mouse cursor).
I noticed that the PreviewKeyDown event fires on tabbing out of the control, but it will also fire if someone simply types text into the control. So
does any expert know how to capture only when someone tabs out of the text box control?

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox1_Leave(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox1_LostFocus(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

End Sub

Private Sub TextBox1_PreviewKeyDown As Object, e As EventArgs) Handles TextBox1.TextChanged

End Sub
0
Greetings

Is there a way to pass to a Crystal Report the database connection? What we are hoping there is way to pass the the report via the VB.NET application the database to connect. This way whether we are publishing our application to a Test/Q&A server or to a production server, we do no need to edit the connection in each report prior to publishing.
0
I ant to declare a variable in the following code used with an API but
I get an error showing that the variable is hidden in an encclosong blocck


If Hosting.HostingEnvironment.IsDevelopmentEnvironment Then
                Dim myxeroconsumer As New Consumer("xxx", "yyyy")
            Else
                Dim myxeroconsumer As New Consumer("gggg", "jjjjj")
            End If
0
I am doing this:

   cmbRunList.Items.Add(myreader("Run Description").ToString())


This run description is what i am shown. How do i add a hidden value to the dropdown that is not shown but i am able to use latter in the code?
0
Hi. In ASP.net what VB.net code would I use to see if the site has been published. I have to run slightly different code to what I run in debug mode.
0
I want to practice vb.net by creating a few applications.  I can't seem to find a free download that when i download contains vb.net. Where can i go to download this?
0
Hi. When I select an item in my ASP.net DropDownList I don't see the value in the variable P below
Also after the section the DropDownList text is  blank. What might cause this

    Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList1.SelectedIndexChanged


        Dim P As String = Me.DropDownList1.Text

    End Sub
0
Hi
I currently use the following connection string in my VB.net code to connect to a local database
Server=(localdb)\MSSQLLocalDB;Integrated Security=true
What connection string would I use to connect to the local database shown in the following image
Image1.jpg
0
Hi

I am used to creating an email body using html in a VB.net string.
I have now been asked to create an email body from a SQL ntext field.
How would I do this in VB.net? Is it similar?
0
Hi

I am using my local host to authenticate into the Xero API

Dim myxerocallbackurl = "https://localhost:51970/Default.aspx"

but am getting the following error

oauth_problem=parameter_rejected&oauth_problem_advice=Callback%20url%20is%20not%20in%20the%20registered%20callback%20domain

what are the possible causes? In my Xero app do I have to specify the local host?
0
Hi all.

I have a checkedlistbox that I populate via the code below. I also added a ContextMenuStrip that when the end user right clicks a row (regardless if it's checked or not) I want to be able to edit the text. To do this I need to get the SelectedValue but unfortunately with the code below, the SelectedValue (i.e. StepID) is blank.

What am I doing wrong? Thank you in advance.

Private Sub LoadSteps()
CheckedListBox_OpportunitySteps.Items.Clear()

        Dim con As New SqlConnection
        Dim cmd As New SqlCommand

        con.ConnectionString = "Data Source=myserver;Initial Catalog=mydatabase;Integrated Security=True"

        con.Open()

        cmd.Connection = con

        cmd.CommandText = "SELECT Step, Completed, StepID FROM CRMOpportunitySteps WHERE OpportunityID = @OpportunityID ORDER BY StepID"
        cmd.Parameters.AddWithValue("@OpportunityID", opportunityID)

        Dim sda As New SqlDataAdapter(cmd)
        Dim dt As New DataTable()

        sda.Fill(dt)

        CheckedListBox_OpportunitySteps.DisplayMember = "Step"
CheckedListBox_OpportunitySteps.ValueMember = "StepID"

If dt.Rows.Count > 0 Then
            For i As Integer = 0 To dt.Rows.Count - 1
 CheckedListBox_OpportunitySteps.Items.Add(CStr(dt.Rows(i).Item(0)), dt.Rows(i).Item(1))

            Next
 End If
    End Sub

Private Sub EditToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles EditToolStripMenuItem.Click

        
        Dim itm As String

        itm = 

Open in new window

0
I am having issues trying to populate a datagrid that has predefined columns. The array is 46 in length and I am trying to populate each row with the right information.

I have the code below but it only populates the first first and the first 3 cells. In the 4th cell I do have a combox, could this be what is holding it up?

  ArrayGWHIZModel = strDataCOM1.Split(New Char() {Chr(13)}, StringSplitOptions.RemoveEmptyEntries)
                    If ArrayGWHIZModel.Length = 46 Then
                        'DataGridView1.Rows.Add(ArrayGWHIZModel(0), ArrayGWHIZModel(1), True, ArrayGWHIZModel(3), True, ArrayGWHIZModel(5), ArrayGWHIZModel(6), ArrayGWHIZModel(7), ArrayGWHIZModel(8), ArrayGWHIZModel(9))
                        'DataGridView1.Rows.Add(ArrayGWHIZModel(0), ArrayGWHIZModel(1), ArrayGWHIZModel(2), ArrayGWHIZModel(3), ArrayGWHIZModel(4), ArrayGWHIZModel(5), ArrayGWHIZModel(6), ArrayGWHIZModel(7), ArrayGWHIZModel(8), ArrayGWHIZModel(9))
                        'DataGridView1.Rows.Add(ArrayGWHIZModel(0), ArrayGWHIZModel(1), ArrayGWHIZModel(2), ArrayGWHIZModel(3), ArrayGWHIZModel(4), ArrayGWHIZModel(5), ArrayGWHIZModel(6), ArrayGWHIZModel(7), ArrayGWHIZModel(8), ArrayGWHIZModel(9))
                        'DataGridView1.Rows.Add(ArrayGWHIZModel(0), ArrayGWHIZModel(1), ArrayGWHIZModel(2), ArrayGWHIZModel(3), ArrayGWHIZModel(4), ArrayGWHIZModel(5), ArrayGWHIZModel(6), ArrayGWHIZModel(7), ArrayGWHIZModel(8), ArrayGWHIZModel(9))
                        

Open in new window

0
Greetings:

I am quite confused as to what I can do and what I cannot do within the UploadComplete event of the AjaxFileUpload control.

There are 2 ASPX Label controls which are assigned values within the UploadComplete event, however, the assigned values do not appear on the page after the event completes. The uploaded file is saved to the designated directory, however.

I'm including the ASPX, the VB code behind and the web.config files as follows:

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
	<title></title>
</head>
<body>
	<form id="form1" runat="server">
		<div>

			<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

			<asp:Label ID="Label1" runat="server"></asp:Label>

			<ajaxToolkit:AjaxFileUpload ID="AjaxFileUpload1" runat="server" AllowedFileTypes="jpeg,jpg,gif" />

			<asp:Label ID="Label2" runat="server"></asp:Label>

		</div>
	</form>
</body>
</html>

Open in new window

VB Code Behind
Imports AjaxControlToolkit

Partial Class _Default
	Inherits System.Web.UI.Page

	Private Sub AjaxFileUpload1_UploadComplete(sender As Object, e As AjaxFileUploadEventArgs) Handles AjaxFileUpload1.UploadComplete

		Label1.Text = "Here we are 1."

		AjaxFileUpload1.SaveAs("C:\inetpub\ClientWebs\AjaxFileUploadSync\Images\" & e.FileName)

		Label2.Text = "Here we are 2."

	End Sub

End Class

Open in new window

web.config
<?xml version="1.0" encoding="utf-8"?>

<configuration>

	<system.web>
		<compilation debug="true" targetFramework="4.0" />
	<pages>
      <controls>
        <add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
      </controls>
    </pages></system.web>

	<system.webServer>

		<handlers>

			<add name="AjaxFileUploadHandler" verb="*" path="AjaxFileUploadHandler.axd" type="AjaxControlToolkit.AjaxFileUploadHandler, AjaxControlToolkit" />

		</handlers>

	</system.webServer>
</configuration>

Open in new window

Any assistance you might provide would be most helpful.


Much thanks,
David Bach
0
Hi.  There are times when DNS and a PC name do not match, and can determine this with PING -a, for example, I ping Computer 1 and returns an IP address, then PING -a the IP address and find the IP is associated with Computer2. I once wrote a simple batch that pinged the PC by name, captured the IP, then PING -a and if the PC names don't match, there's a conflict. That worked well.

Is there an elegant way to do this type of verification in VB.net?   I have an app that depends on connectivity to a remote PC host (on an AD domain), but it fails if there's a DNS conflict.  I'd like to verify there's an actual DNS issue in VB, instead of calling on CMD to check.
0

Visual Basic.NET

94K

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,