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'm using a select2 multiple dropdownlist. I am getting the above error.
I've seen posts where they say this error occurs if you have two items in the list with the same value, but I do not have that and I also use the "multiple" option.

    <select name = "ctl00$ContentBody$TeamProfileControl$ddlDistrictId" id="ddlDistrictId" Class="ddlSelectMultiple" name="ddlDistrictId" multiple="multiple" style="width:100%;">
    	<option value = "1786" > AP_Test_District</Option>
    	<option value = "209" > Honey Dew South</Option>
    	<option value = "562" > HQ</Option>
    	<option value = "38" > JK&#39;s Crib</Option>
    	<option value = "206" > Kansas City Office</Option>
    	<option value = "759" > Testing District</Option>

    </select>

Open in new window


I also read to add items this way, however, I populate with a sql databind, so using this is not applicable:
DDLModality.Items.Add(Li1)

I need to preselect the previously saved values in the dropdownlist to display them as selected on the screen. Here is my code, it runs with no errors but when the screen is loaded it generates:
Cannot have multiple items selected in a DropDownList.

   Public Sub CheckMultiListBoxNumeric(ByRef ddlDistrictId As DropDownList, ByVal districtIds As String)

        ddlDistrictId.ClearSelection()

        Dim checkedItems As String()
        checkedItems = Split(districtIds, ",")
        Dim selected As List(Of String) = checkedItems.ToList()

        For Each row As String In selected


            If ddlDistrictId.Items.FindByValue(row) IsNot Nothing Then
                ddlDistrictId.Items.FindByValue(row).Selected = True
            End If


        Next

Open in new window

0
Fundamentals of JavaScript
LVL 13
Fundamentals of JavaScript

Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.

I want to send some commands to minecraft on windows 10...specifically to hold down the 'W' key so that my game will move forward for X miliseconds, then release, then send a spacebar to "Jump".  Using sendkeys doesn't work so well for me because they send single keystrokes and I'd like to hold keys down.  How can I do this?  I use vb.net 2017.  Thank you!
0
Hi All,

Hope your well,

I have a VB script which is nearly there but just a small part missing.

The script is being configured to delete certain contacts with a particular attribute set. Within that subset of contacts with this particular attribute im also adding some additional logic to not delete all of them e.g.

as an example: I look for contacts with extensionattribute1 set with "SPECIALATTRIBUTE", I then say, if email address 2 is populated DO NOT DELETE, move on to the next. My aim is to delete all of these contacts without an email address 2 set. The bit where im stuck is that I'm also trying not to delete contacts that have a certain domain e.g outlook.com but im not sure on the contains context. My ultimate goal is to look for contacts with a particular attribute, keep the ones that have an Email2address set and if their email1address contains outlook.com and then delkete the rest that do not match these conditions.


Set objRecord = objItem.Find("[Extensionattribute1] = ""SPECIALATTRIBUTE""")

While Not objRecord Is Nothing
     
      If objRecord.Email2Address = "" And objRecord.Email1Address <> "*OUTLOOK.com" Then objRecord.Delete

      Set objRecord = objItem.FindNext

Many Thanks.
0
Hello,
How to give users the Printpreview for color settings in vb.net
Regards
0
Hi All,

Hope your well,

I have a VB script which is nearly there but just a small part missing.

The script is being configured to delete certain contacts with a particular attribute set. Within that subset of contacts with this particular attribute im also adding some additional logic to not delete all of them e.g.

as an example: I look for contacts with extensionattribute1 set with "SPECIALATTRIBUTE", I then say, if email address 2 is populated DO NOT DELETE, move on to the next. My aim is to delete all of these contacts without an email address 2 set. The bit where im stuck is that I'm also trying not to delete contacts that have a certain domain e.g outlook.com but im not sure on the contains context. My ultimate goal is to look for contacts with a particular attribute, keep the ones that have an Email2address set and if their email1address contains outlook.com and then delkete the rest that do not match these conditions.


Set objRecord = objItem.Find("[Extensionattribute1] = ""SPECIALATTRIBUTE""")

While Not objRecord Is Nothing
      
      If objRecord.Email2Address = "" And objRecord.Email1Address <> "*OUTLOOK.com" Then objRecord.Delete

      Set objRecord = objItem.FindNext

Many Thanks.
0
I have asp.net website and I want to record changed field in to log table, for eg. That page has 20 textbox then I want to know which field User changed out of 20, so I can maintain
that in log table, Please let me know
0
We sell commercially an application developed in Visual Basic .NET (currently in VS 2008, though we're looking at making the upgrade to VS 2019). Reports from the application can be output as either Crystal Reports text reports displayed on screen or native Microsoft Excel files (created using Automation). One of our customers has told us that their auditors are requiring that they produce reports which are provably unaltered. While Excel is a format they prefer, there's no way to know if the cells were changed after the file was created, so for the time being they're giving their auditors Crystal Reports output exported to PDF.

If I could digitally sign the Excel file I create, I believe that would meet the audit requirement. However, I can't figure out a way to sign a document under program control, with a signing certificate that would be held safely inside the executable and couldn't be hijacked. Is this a pipe dream, a self-contradictory desire? Or is there a way to make this work? Or is there another way to accomplish the same thing, of an Excel file that can be reliably locked when it's created by a Visual Basic application?
0
Hi All,

I want to send message to WA from desktop application using https://web.whatsapp.com/

Please see below code.

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MaiWA
{
    public class CWhatsapp
    {
        private const string QR_CODE_XPATH = "//img[@alt='Scan me!']";
        private const string SEARCH_INPUT_XPATH = "//input[@title='Search or start new chat']";
        private const string CHAT_INPUT_XPATH = "//div[@class='_2S1VP copyable-text selectable-text']";
        //private static int TUNDA = 2000;
        private static IWebDriver _driver = null;

        public void StartWhatApp()
        {
            _driver = new ChromeDriver(new ChromeOptions { LeaveBrowserRunning = false });
            _driver.Url = "https://web.whatsapp.com";

            _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(20);
            _driver.Navigate();
        }

        public bool OnLoginPage()
        {
            try
            {
                if (_driver.FindElement(By.XPath(QR_CODE_XPATH)) != null)
                {
                    return true;
                }
            }
            catch
            {
                return false;
            }
            return false;
        }

        public void StopWhatApp()
        {
            _driver.Quit();
            _driver.Dispose();
        }

        public bool KirimText(string 

Open in new window

0
I am trying to move a large Visual Basic .NET project from VS 2008 to VS 2019 Community Edition. In VS 2019, I am getting huge numbers of errors like

Requested operation is not available because the runtime library function 'System.Runtime.CompilerServices.AccessedThroughPropertyAttribute..ctor' is not defined.

Other functions are named on other occasions, such as "System.Runtime.CompilerServices.DateTimeConstantAttribute..ctor".

Even more strangely, I'm getting error BC30002, "Type 'System.String' is not defined", and the same error for other types (Void, Int32, DateTime, Decimal, etc.).

Clearly, some sort of reference linking the Windows forms app to runtime modules isn't getting loaded, but I can't figure out what's missing. I've looked at the VS 2019 version and the VS 2008 version, and the project references seem to match. Can you offer suggestions of how to get them properly loaded, and eliminate the current 75,000(!) errors?
0
Need to create setup app using MS Installer, VB.NET, and VS2017.

So far no coherent step-by step instructions for the MS Installer is found.

The efforts to produce this instructions (video, web page) is much appreciated. However, nothing works.

Posting a question is not possible because it's not yet known. Thank you for the help.
0
OWASP Proactive Controls
LVL 13
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

How to create a datatable with the time format string incremeted with nearest 15 minutes.
I am using vb.net

example:

Dim dt as new datatable

If the string value is 2:32 then the datatable should have rows in time incrementing by around 15 minutes :

Having rows like :

2:45
3:00
3:15

example2:
String value is 4:34 then the datatable should have rows in time incrementing by around 15 minutes :

Having rows like :

4:45
5:00
5:15

Please let me know if you have any further queries.

Regards
2
I don't need a lesson on how to use an Event with a control in a control. The problem here is that the event is in a repeater in a control within the repeater:
                <asp:Repeater ID="repRows" runat="server">
                    <ItemTemplate>
                        <uc:BulkRow runat="server" ID="BulkRow" ></uc:BulkRow>
                    </ItemTemplate>
                </asp:Repeater>

Open in new window


I have a repeater in the parent control. Inside the repeater is a child control that contains all of the form elements.

When the submit button is clicked for that row in  the child form elements control, I want to raise an event to trigger something in the parent control that has the actual repeater.

However, it is not triggering my parent repeater control's event handler.

Example:
BulkControl - parent
contains repeater and defines the handler on the ItemDataBound:
 
    Dim bulkRowCtrl As BulkRow = CType(e.Item.FindControl("BulkRow"), BulkRow)
        AddHandler bulkRowCtrl.AlertEvent, AddressOf AlertEventHandler

Open in new window


BulkRow child Control contains the event:
    Public Event AlertEvent(ByVal alertMessage As String)

Open in new window

and raises the event:
               
 RaiseEvent AlertEvent(alertEventMessage)

Open in new window


When I raise the event within the child control, it never triggers it in the parent control.
0
Need to read 2 values from a query in vb.net

 cn.Open()
            Dim nusa15 As String = "SELECT pagadot,nombre  FROM cheque WHERE id = '" & CustomerId & "'"
            Dim cmd15 As New OleDbCommand(nusa15, cn)
            valor = (cmd15.ExecuteScalar())
            cn.Close()

Open in new window



this one get me only pagadot that i asign to valor

how to get nombre in the same

what is the way dear experts
0
I am new to using web services.  I've created the Web Reference to the following Web Service: https://www.odfl.com/wsRate_v6/RateService?wsdl
And I was giving the following sample code: (see attached Sample Home More Request.xml)
I don't know how to move forward now that I created the Web Reference. My project is in VB.NET
0
How do you make a compatible referencing for Office libraries to work with Office 2010 and above while using  Visual Basic? I am using MS office object libraries. I also reference MS Excel Object Library. Will that be a problem?
0
I need to implement Google reCaptcha on an old ASP.NET VB Webforms platform and I need a complete code that would help me do that.

I haven't done VB before and have done some webforms development long time ago.

I have followed the instructions of the following link but can't seem to get it right.  I have added the Assembly Recaptcha.dll on the frontend code with the associated VB code inside a <script runat=server> tag just like the guide and after recompiling and replacing the compiled code on the site, it doesn't seem to be able to load the Assembly and pops out the following error message,

Server Error in '/' Application.
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Could not load file or assembly 'Recaptcha, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. A strongly-named assembly is required. (Exception from HRESULT: 0x80131044)

Source Error: 

Line 1:  <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="register.aspx.vb" Inherits="Website.Members.clsRegister_Page" %>
Line 2:  
Line 3:  <%@ Register TagPrefix="uc1" TagName="ucMessageBox" Src="../controls/ucMessageBox.ascx" %>

Open in new window


All in all if you could help with with the exact implementation code, I would really appreciated it.
0
I just got Visual Studio 2019 installed on my PC at work, and I want to create an install package for a VB.Net application, that package will run on a Windows Server 2012 or 2016.

However, the Application Packaging Project, which seems to be the way to create such an install kit, only supports packaging for Windows 10 in its corresponding dropdowns. How can I generate an install kit for Windows Server 2012 or 2016 ?

Thanks for help
Bernard
0
Anyone know how to get S.M.A.R.T. drive info from vb.net?

https://code.msdn.microsoft.com/Working-with-Windows-d2509544
https://www.thewindowsclub.com/hard-disk-drive-health

i.e. id like to call a function and have it return if the drive is OK or having issues. Being as smart is enabled and we can query WMIC, id think this is possible. Anyone know how i could modify the above code examples to get that?

Thanks!
0
In radSpreadSheet how can I set a cell value by its name? meaning excel cell "B1" for example
0
CompTIA Network+
LVL 13
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

I click a button to  load an Excel file from a website via a Export to excel menu choice! The code below works fine and
opens the File download window except the newly opened 'save file to' window only opens
when the code exits the subroutine and wait for a new user input! .
How do I continue executing the second part of code that clicks the save button to actually save the file
as the window doesn't open until the first part finishes executing!  



Imports System.Runtime.InteropServices
Imports System.Text

Public Class activeWin

    Private Sub ActiveWin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        GetActiveWindows()
    End Sub
    'Public Delegate Function CallBack(ByVal hwnd As Integer, ByVal lParam As Integer) As Boolean
    Public Delegate Function CallBack(ByVal hwnd As IntPtr, ByVal lParam As Integer) As Boolean
    Public listcount As Integer = 0
    Public Declare Function EnumWindows Lib "user32" (ByVal Adress As CallBack, ByVal y As Integer) As Integer
    Public Declare Function IsWindowVisible Lib "user32.dll" (ByVal hwnd As IntPtr) As Boolean
    Private Const SW_HIDE As Integer = 0
    Private Const SW_RESTORE As Integer = 9
    Public hwnd As IntPtr
    Public selectedIndex As Integer
    Public xAsIntPtr, cxAsIntPtr As IntPtr
    Private ActiveWindows As New System.Collections.ObjectModel.Collection(Of IntPtr)
    <DllImport("User32")> Private Shared Function ShowWindow(ByVal hwnd As IntPtr, ByVal nCmdShow As

Open in new window

0
Hello Experts,
I am trying to debug a Stored Procedure from Visual Studio 2013.  I have already done the followings.  When tried to Execute the code, the break points works in C# code.  But in the SP the Break Point displays the message "the breakpoint will not currently be hit...", and never goes there.  Please let me know if I am missing anything.

Under View --> Server Explorer --> Added the Database.  Picked the Stored Procedure and added the Break Points.  Also added the Break Point in the C# code in VS.

Thank you very much in advance.
0
I access a web page via code and try to export and download an excel file. But at the usual 'Open Save Cancel' window I can't get the save button to fire!
I found a few similar posts here but the solutions found don't work!

Here is what I have !

Code:
        Sub ClosePopup(ByVal WindowHandle As IntPtr)

        Dim clsChildHandles As ArrayList = GetChildWindowHandles(WindowHandle)
        Dim teststr As String
        Dim prthandleint As Long
        'look through all of the child handles of the window for an "Save" button (this method
        'can also be used to gather more specific information about the dialog itself, such as
        'the message being displayed)...
        For Each ptrHandle As IntPtr In clsChildHandles
            'if the Save button is found, click it...
            teststr = GetWindowText(ptrHandle)
            prthandleint = ptrHandle ' was having trouble with putting an intptr in debug.print!
            Debug.Print(teststr & " = Child TEXT:   len=" & teststr.Length & "handle = " & prthandleint & vbCrLf)

            If teststr.Contains("&Save") Then
                ClickButton(ptrHandle)  ' THIS PART WORKS AS I GET HERE!
                Exit For
            Else
                Debug.Print(teststr & " = ELSE Child TEXT:   len=" & vbCrLf)
            End If
        Next

    End Sub
 
    Const BM_CLICK As Long = &HF5&
    Public Const WM_LBUTTONDOWN As UInteger = &H201
    Public Const WM_LBUTTONUP As UInteger…
0
i had a datagrid control that reports out a series of values. I would like to bind those values in a chart control object so that if I select a value on the datagrid then it will highlight in the chart.

What are the binding properties to do this?
0
I know this will be simple but I cant seem to get there without help.


I have a VB.net project and I want to print onto multiple pages.  Could someone please take a look at the attached code a tell where I'm going wrong.

Private Function PreparePrintDocumentVATDetail() As PrintDocument
        ' Make the PrintDocument object.
        Dim print_document As New PrintDocument

        ' Install the PrintPage event handler.
        AddHandler print_document.PrintPage, AddressOf Print_PrintPageVATDetail

        ' Return the object.
        Return print_document
    End Function

    Private Sub Print_PrintPageVATDetail(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)

        Dim bottomMargin As Integer = Me.PrintDocument1.DefaultPageSettings.Margins.Bottom / 2
        Dim topMargin As Integer = Me.PrintDocument1.DefaultPageSettings.Margins.Top / 2
        Dim leftMargin As Integer = Me.PrintDocument1.DefaultPageSettings.Margins.Left
        Dim rightMargin As Integer = Me.PrintDocument1.DefaultPageSettings.Margins.Right

        Dim pageHeight As Integer = Me.PrintDocument1.DefaultPageSettings.Bounds.Height - topMargin - bottomMargin
        Dim pagewidth As Integer = Me.PrintDocument1.DefaultPageSettings.Bounds.Width - leftMargin - rightMargin
        Dim fontHeight As Integer = Me.lstCustCode.Font.Height
        Dim itemCount As Integer = pageHeight / fontHeight
        Dim x As Integer = leftMargin + 10
        Dim y As Integer = 

Open in new window

0
Adding items to a combo box
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,