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

Hi,

   The following is my code- To detect which key I press, and it can work well.
  <asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1">
   <script language="VBScript" type="text/vbscript">
      Sub document_onkeydown()
       if (window.event.keyCode="113") then
        document.getElementById("<%=A.ClientID %>").focus()
       elseif (window.event.keyCode="121") then
        document.getElementById("<%=B.ClientID %>").focus()
       elseif (window.event.keyCode="118") then
        document.getElementById("<%=C.ClientID %>").checked=true
       elseif (window.event.keyCode="119") then
        document.getElementById("<%=D.ClientID %>").checked=true
        document.getElementById("<%=E.ClientID %>")
       elseif (window.event.keyCode="120") then
        document.getElementById("<%=F.ClientID %>").checked=true  
       End If
      End Sub
    </script>

    <asp:UpdatePanel ID="UpdatePanel1" runat="server" RenderMode="Inline" ViewStateMode="Enabled"
            UpdateMode="Conditional">
            <ContentTemplate>
    .......
    .......
    </asp:UpdatePanel>
  </asp:Content>

    Now I use updatepanel control in asp.net(VB),I can't detect which key I press. What is this error and how can I resolve it ?  Thanks.
0
We currently have a vb.net application that is connected to a SQL server database through LINQ, table adapters and stored procedures.
For a while now we have been getting a lot of problems with things like double adjustments sale not processing etc - (When a sale is processed for example the stored procedure for the sale are run twice, other times is does not run at all and most of the time the sale is processed correctly, we think this could be caused by deadlocks but we are unsure. When a sale is processed, we sometimes get that the stock has been adjusted incorrectly – double adjustments. These problems are currently occurring at our bigger clients).
Someone has mentioned making use of a transaction manger. The only one that I could find that is compactable with SQL server was Java database Connectivity (JDBC). Are there other transaction manager options we can use?
Or must we fix all the SQL in our application using SQL transactions?
0
I was using Virtual directory on IIS website, But I dont understand its significance , I have set Virtual director as another server IP for eg \\192.168.2.2\Download and I wanted to upload my file on Virtual director so its automatically get copied to \\192.168.2.2\Download location but it seems to upload on same server where IIS website is set,  Please let me know if anyone has idea on that.
0
I have mapped network drive to one of server for eg. Y drive which is connected with another server \\192.168.1.1
I am trying to upload file on Y drive but its throwing error, Please help me for same.
Below is my code

If fuSheet.HasFile Then
               'UploadPath = Server.MapPath("~/Y:/") + "Project" + ProjectId + "_" + fuSheet.FileName
 
                fuSheet.SaveAs(UploadPath)
                Path = UploadPath
            End If

Open in new window


Error is : fileUpload.Error:The given path's format is not supported.

If I change code like that
If fuSheet.HasFile Then
               'UploadPath = Server.MapPath("/Y:/") + "Project" + ProjectId + "_" + fuSheet.FileName
 
                fuSheet.SaveAs(UploadPath)
                Path = UploadPath
            End If

Open in new window


Then Error: fileUpload.Error:The given path's format is not supported.

If I change code like below
If fuSheet.HasFile Then
               'UploadPath = Server.MapPath("Y:/") + "Project" + ProjectId + "_" + fuSheet.FileName
 
                fuSheet.SaveAs(UploadPath)
                Path = UploadPath
            End If

Open in new window

Then Error fileUpload.Error:'Y:/' is a physical path, but a virtual path was expected.
0
After a ListBox is populated some items must be selected. There is no mechanisms for selecting individual items. True also for ListView.    
This is as far as I got. Thank you for any advice.

Public Sub HightlightListItems(list As ListBox, strSelectToItems As String)
            Dim intItemCount As Int16 = ItemCount(list)
            Dim strItem As String
            For index As Int16 = 0 To intItemCount - 1
                strItem = list.Items(index)
                If InStr(strItem, strSelectToItems) Then
                    list.Items(index) <<  here is where the selection should be made
                End If
            Next
    End Sub

    Public Function ItemCount(lst As ListBox) As Int16
        Try
        Dim count As Int16 = 0
            Do
                count = count + 1
            Loop
        Catch ex As Exception
            Return count  << bail on exception
        End Try
    End Function
0
I have created Virtual Directory named as Downloadserver on my website IIS (192.168.1.1\Download), That 192.168.1.1 is another server, while website is setup on 192.168.1.2,  , Now I am trying to upload file there using below code:
 Dim filenamepath As String = System.IO.Path.Combine(Server.MapPath("~/DownloadServer/"), fuSheet.FileName)
 fuSheet.PostedFile.SaveAs(filenamepath)

 But its not uploading file on \\192.168.1.1\Download location, Please help me to understand this.
0
I am using asp.net website, I want code which will allow me to upload and download on different server using network drive, for eg. Network drive is \\192.168.1.1
UserName=aaa, Password=aaa
Then  It should upload and download file on that location. Please help me for same.
0
Hi Experts,

I have below code.

   Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean

        If Not blnGridOnFocus Then
            Return MyBase.ProcessCmdKey(msg, keyData)
        End If


        If keyData = Keys.Enter Or keyData = Keys.Tab Then

            With dgvBarang

                .EndEdit(True)

                Dim dgvRow As DataGridViewRow
                dgvRow = .Rows(.CurrentRow.Index)

                Dim strColumnName As String = ERV_Global.Get_Column_Name_From_Datagridview(
                         dgvBarang,
                         .CurrentCell.ColumnIndex)

                Select Case strColumnName

                    Case "HargaSatuan"

                        If Not IsNumeric(dgvRow.Cells("HargaSatuan").Value) Then
                            dgvRow.Cells("HargaSatuan").Value = 0
                            .Rows(.CurrentRow.Index).Cells("SatuanCode").Value = .Rows(.CurrentRow.Index).Cells("SatuanCode").Value
                        End If

                        .CurrentCell = .Rows(.CurrentRow.Index).Cells("SatuanCode")

                    Case "SatuanCode"

                        If .CurrentRow.Index < .Rows.Count - 1 Then
                            .CurrentCell = .Rows(.CurrentCell.RowIndex + 1).Cells("HargaSatuan")
                        Else

                            cboForGrid.Visible = False

                            

Open in new window

0
I am using vb.net to create graph using excel charts but the excel charts are the images. now i wish to change to graphs as per the input provided without images. kindly help?
0
I am using Asp.net website 3.5 and trying to connect with MYSQL, I have installed mysql software and created DB,NEW USER, TABLE and trying to use that on Asp.net code, when I tried
then its giving me error:
MySql.Data.Mysql.Client provider not registered on local machine, I even add MySql.Data dll on my website still error not going, here is my web.config file:

<?xml version="1.0"?>
<configuration>
  <appSettings/>
  <connectionStrings>
    <add name="WebAppConString" connectionString="server=127.0.0.1,User Id=webuser;Password= webuser2020;Port=3306; Database=webappdemo;" providerName="MySql.Data.Mysql.Client"/>
    <!--<add name="WebAppConnString" connectionString="Server=127.0.0.1;UserID=webuser;Password=webuser2020;Database=webappdemo1;Port=3306;" providerName="MySql.Data.Mysql.Client"/>-->
  </connectionStrings>
  <system.web>
    <!-- 
            Visual Basic options:
            Set strict="true" to disallow all data type conversions 
            where data loss can occur. 
            Set explicit="true" to force declaration of all variables.
        -->
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0">
      <assemblies>
        <add assembly="MySql.Data, Version=8.0.19.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
        <add assembly="MySql.Web, Version=8.0.19.0, Culture=neutral, PublicKeyToken=C5687FC88969C44D"/>
      </assemblies>
    </compilation>
    <!--
          The <authentication> section 

Open in new window

0
I need a Autocomplete search in a text box(like Google search) and the values are from arraylist. The value selected should also be selected in Radgrid
0
I'm running a request that should return orders that are processing.
However, when I change the status in WooCommerce to On Hold, or something other than Processing - I still get the previous results, even if new orders are marked Processing.

Sometimes this clears up if I wait awhile.  If I test the same results in PostMan - i get the correct results.

Here's my code for getting the data:

Function WRequest(URL As String, method As String, POSTdata As String) As String
        Dim responseData As String = ""
        Try
            Dim cookieJar As New Net.CookieContainer()
            Dim hwrequest As Net.HttpWebRequest = Net.WebRequest.Create(URL)
            hwrequest.CookieContainer = cookieJar
            hwrequest.Accept = "*/*"
            hwrequest.AllowAutoRedirect = True
            hwrequest.UserAgent = "http_requester/0.1"
            hwrequest.Timeout = 60000
            hwrequest.Method = method
            If hwrequest.Method = "POST" Then
                hwrequest.ContentType = "application/x-www-form-urlencoded"
                Dim encoding As New Text.ASCIIEncoding() 'Use UTF8Encoding for XML requests
                Dim postByteArray() As Byte = encoding.GetBytes(POSTdata)
                hwrequest.ContentLength = postByteArray.Length
                Dim postStream As IO.Stream = hwrequest.GetRequestStream()
                postStream.Write(postByteArray, 0, postByteArray.Length)
                postStream.Close()
            End If
          

Open in new window

0
I am using asp.net website, I am using upload tool, what I am looking is to upload my files on network drive, Also that drive should be mapped throgh asp.net using Network url, Username and password. It should setup an network upload file there and get disconnected, is it possible, Please help
0
I have purchased hosting package on Godaddy server, I have added one domain there, now I want to run my Asp.net website pages there, I am using asp.net with vb website 3.5/4.0, Can
I setup that on Godaddy, I saw there is plex admin, Please help me to setup my website there.
0
Hello,

I am looking for the equivalent in VB.NET (or in C #) of the following PHP code

$params = array(
  'http'=>array(
    'method'=>"POST",
    'header'=>"content-encoding: amz-1.0 ....Signature=1c1b2f3c38bac12904cf84",
    'content' =>"example")
);
$stream = stream_context_create ( $params );

$fp = @fopen ( 'http://www.example.com, 'rb', false, $stream );

$response = @stream_get_contents ( $fp );
0
Hi
The following ASP.net VB.net code works in debug mode but does not work after I publish the site. Why might this be? Thanks

    Protected Sub btnContactMe_Click(sender As Object, e As EventArgs) Handles btnContactMe.Click

        Try
            Dim S As String = "Office2Web Enquiry "
            'NOTE OUNCTUATION MESSES WITH EMAILING
            S = S & "Name " & Me.txtName.Text & " Email " & Me.txtEmail.Text & " Contact Number " & Me.txtContactNumber.Text & " Company " & Me.txtCompany.Text
            S = S & " Description " & Me.TextBox1.Text
            Dim sEmailResult As String
            ''sEmailResult = oSendMailMessage("info@online-excel.com", "consulting@office2web.com.au", "murray@office2web.com.au", "", "Office2Web Enquiry", S, True)
            sEmailResult = oSendMailMessage("info@online-excel.com", "consulting@office2web.com.au", "murbro9@yahoo.com", "murray@office2web.com.au", "Office2Web Enquiry", S, True)

            If sEmailResult = "Email Success" Then
                Me.lblEmailResult.Text = "Message Sent. Thank you."
            Else
                Me.lblEmailResult.Text = "Sorry! Message not sent. " & sEmailResult
            End If
        Catch ex As Exception
            Me.lblEmailResult.Text = "Error message not sent " & ex.Message
        End Try

    End Sub

    Public Function oSendMailMessage(ByVal from As String, ByVal recepient As String, ByVal bcc As String,
                             ByVal cc As String,…
0
A corporate network has an email account where no authentication is required to send emails internally

I'm a little unsure how its done as the SmtpClient needs authentication (as I can see)

They gave me a code sample which works on their end


.Item(cdoSendUsingMethod) = cdoSendUsingPort

.Item(cdoSMTPServerPort) = 25

.Item(cdoSMTPServer) = "mail.theircorp.com" 

.Item(cdoSMTPAuthenticate) = cdoBasic

.Item(cdoSendUserName) = "nouser@theircorp.com"

.Item(cdoSendPassword) = ""

.Item(cdoSendEmailAddress) = "nouser@theircorp.com"

Open in new window


But I assume this is old tech.


How would I achieve this using SmtpClient
0
I am trying to get the following "SharePoint Hello Word" to work:

Sub Main()

    ServerUrl = "https://companyname.sharepoint.com/sites/TestingWeb"
    Using Context As New Client.ClientContext(ServerUrl)

            AddHandler Context.ExecutingWebRequest, AddressOf ExecutingWebRequest_Handler
            Context.AuthenticationMode = Client.ClientAuthenticationMode.Default
            Context.Credentials = System.Net.CredentialCache.DefaultCredentials

            Dim ThisWeb As Client.Web = Context.Web
            Context.Load(ThisWeb)

            Context.ExecuteQuery()
            MsgBox($"Web = {ThisWeb.Title}")

    End Using

End Sub

Private Shared Sub ExecutingWebRequest_Handler(sender As Object, e As Client.WebRequestEventArgs)
        Try
            e.WebRequestExecutor.WebRequest.Headers.Add("X-FORMS_BASED_AUTH_ACCEPTED", "f")
        Catch ex As Exception
            MsgBox("Could not append Web Request Header.", vbCritical Or vbOKOnly)
        End Try
End Sub

Open in new window


This code is executed from within a VSTO for Word or Excel, when the user opens a document from one of the SharePoint Document Libraires they have access to.
The end goal will be to perform basic (mostly readonly) operations on files and folders contained within that same Document Library the Word or Excel file was open from.

Since the user needs to be logged in to SharePoint to access the file in the first place, I would like to avoid using Context.Credentials = New SharePointOnlineCredentials(email, password).

When I execute the above code, I get a 401 Unauthorized error. What am I doing wrong?
0
VB application that sends PowerShell commands and receives the output.

I am putting the output in to a List view.

The following works fine:

 
[code]      For Each ID In PSOut

            i = i + 1

            'Dim str(6) As String
            Dim str(ColumnCount) As String
            Dim ItCount As Integer = 0
            Dim itm As ListViewItem

            '     Do While ItCount < ColumnCount
            For Each strHeadDSingle In strHeadD2
                str(ItCount) = ID.Properties("name").Value.ToString() ' ### WORKS FINE
                ItCount = ItCount + 1
            Next
            '    Loop
            '         Name, SamAccountName, EmailAddress, PrimarySMTPAddress, UserPrincipalName, DistinguishedName, Enabled"

            itm = New ListViewItem(str)
            ListView1.Items.Insert(0, itm)
        Next

Open in new window

[/code]


When passed as a variable I get the following:

  For Each ID In PSOut

            i = i + 1

            'Dim str(6) As String
            Dim str(ColumnCount) As String
            Dim ItCount As Integer = 0
            Dim itm As ListViewItem

            '     Do While ItCount < ColumnCount
            For Each strHeadDSingle In strHeadD2
                str(ItCount) = ID.Properties(strHeadDSingle).Value.ToString()          ' ### ERRORS THIS LINE
                ItCount = ItCount + 1
            Next
            '    Loop
            '         Name, SamAccountName, EmailAddress, PrimarySMTPAddress, UserPrincipalName, DistinguishedName, Enabled"

            itm = New ListViewItem(str)
            ListView1.Items.Insert(0, itm)
        Next

Open in new window

     


it works 100% as a stated item.

When I try to make my reusable code I get the following on this line when debugging:

System.NullReferenceException
Object reference not set to an instance of an object.

I have checked and values are there quite happily... but little confused.,

Please advise

Many thanks in advance

R
0
Hi i have a rad grid, where by I am displaying data as pagination in the grid and I need to select particular row based on some conditions.I am able to select the row but sometime it displays the selected row on some other pages.

I need help to display the selected row as first page  or need to display selected as first row.

TIA
0
I need to use hidden process to  open an Mht file in the browser and print it using vb.net
0
Hello Experts,
I have a Windows Service Program.  Sometime the Service fails.  How can I execute the program thru a Web Form?  Please try to help.

Thank you very much in advance.
0
For software packages designing in a desktop environment what program language provides the following improvements.

Support/Communities
Updates
3rd party tools

I have programmed inside of vb.net for 17 years. I am looking at moving over all my desktop code and applications to C# but I am not sure.

I would like some professionals to weight in and let me know their thoughts.
1
I have a VB.net application as well as a paid Ring Central account. I would like to enable user functionality wherein the user can make a call directly from my application without having to manually dial the phone number. I found quite a few implementations across the web with the caveat that they are all intended to be web-based. This is up to and including a widget that ring central publishes.

My question is does anyone know how to implement ring central into a VB.net application or alternately do we know of the service that has an object already designed that simplifies the process? Optimally I would like to stick with ring central because we have many users on that platform already.
0
I'm having a difficult time understanding how to implement Async/Await functions in a VB.NET WindowsForm application.
I have a button click event called "tsmiRefreshTargetedRecipeints_Click".

this button calls a function called "BUILD_RECIPIENT_LISTVIEW".
This function queries a database and is returning thousands of records to a listview, which takes a bit of time, and i want to provide an indicator and have the application more responsive.
I'd be happy if I could get this going in a sub procedure even.

Iv'e tried code examples in may different form, mostly C# examples; but I just can't seem to get it to work.  Is there a simple example that someone could provide as to doing this?  I'm thinking of just using threading and worker threads.
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,