[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x

Visual Basic.NET

93K

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

The following vb code works

But the popup window has the localhost url preceeding the msn one?
http://localhost:54358/http//www.msn.com?SSID=12324

              Dim url As String = "http//www.msn.com?SSID=12324"
                Dim s = "window.open('" + url + "', 'popup_window', 'width=300,height=100,left=100,top=100,resizable=yes');"
                ClientScript.RegisterStartupScript(Me.GetType(), "script", s, True)

Open in new window

0
PMI ACP® Project Management
LVL 12
PMI ACP® Project Management

Prepare for the PMI Agile Certified Practitioner (PMI-ACP)® exam, which formally recognizes your knowledge of agile principles and your skill with agile techniques.

I'm using ASP.NET Web Forms and VB

On my page I have a ASP TextBox and a ASP Button

I'm using the TextChanged event for the textbox.

This is my working code for my page

ASP_TextBox_TextChanged4.aspx

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table>
            <tr>
                <td></td>
                <td><asp:TextBox ID="TextBox1" runat="server" ontextchanged="TextBox1_TextChanged" Text="This is a test"> </asp:TextBox></td>
            </tr>
            <tr>
                <td></td>
                <td><asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></td>
            </tr>
            <tr>
                <td></td>
                <td><asp:Button ID="Button1" runat="server" Text="Button" /></td>
            </tr>
        </table>
    </div>
        <asp:HiddenField ID="HiddenField1" runat="server" />
    </form>
</body>
</html>

Open in new window


ASP_TextBox_TextChanged4.aspx.vb

Partial Class ASP_TextBox_TextChanged4
    Inherits System.Web.UI.Page

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

    End Sub

    'TextBox.TextChanged Event
    ' Occurs when the content of the text box changes between posts to the server.
    

Open in new window

0
I try to add 360° animations to our vb.net based website. An example animation you can see here: http://hedue.de/360/r181/r181.html.

I took the code from the html-file and placed it in the aspx:

<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/hedue.master" CodeBehind="360.aspx.vb" Inherits="hedue_de._360" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
              <title>Rotationslaser hedue S2</title>
        <link rel = "stylesheet" href = "http://www.hedue.de/360/HTML5/HTML5Viewer.css" type = "text/css" />
              <script type = "text/javascript" src = "http://www.hedue.de/360/HTML5/jQuery.js"></script>
        <script type = "text/javascript" src = "http://www.hedue.de/360/HTML5/jQueryPlugin.js"></script>
        <script type = "text/javascript" src = "http://www.hedue.de/360/HTML5/HTML5Loader.js"></script>
        <script type = "text/javascript" src = "http://www.hedue.de/360/HTML5/HTML5Viewer.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
      

              <div id = "Frame" class = "animateCreatorContainer" style="width:600px; height:600px;"></div>
      Art.-Nr. <%=ArtNr%>
        <script type="text/javascript">
                      window.onload = function () {
                          jQuery('#Frame').animate360({
                                centerInWindow: false,
                                xmlPath: 'http://www.hedue.de/360/<%=ArtNr%>/',
                                objPath: …
1
Hello,
How do I add my vb.net desktop project to git.
I am using visual studio 2017 .

Thanks
0
Hello,
Any suggestion for certification for AI & ML .
I am a VB.Net desktop ddeveloper.
Any suggestions ae appreciated.
Thanks
0
Hi

I am reading a text file using a StreamReader.

The issue I am having is if the text has a $ sign.

It replaces the $ sign with ChrW(128).

Instead of "SMSENRA$" I get "SMSENRA" & ChrW(128)

 Private Sub LoadTrans_Table()
        Try

            Trans_Table = New DataTable



            Dim firstLine As Boolean = True

            Dim StreamEncoding As Encoding

            StreamEncoding = Encoding.UTF7


            Using sr As New StreamReader(fi.FullName, StreamEncoding)
                While Not sr.EndOfStream

                    If firstLine Then
                        firstLine = False
                        Dim cols = sr.ReadLine.Split(",")
                        For Each col In cols
                            Trans_Table.Columns.Add(New DataColumn(col, GetType(String)))
                        Next

                    Else

                        Dim data() As String = sr.ReadLine.Split(",")
                        Trans_Table.Rows.Add(data.ToArray)
                    End If

                End While
            End Using


         
        Catch ex As Exception
            MessageBox.Show(ex.Message, "LoadTrans_Table()", MessageBoxButtons.OK, MessageBoxIcon.Error)

        End Try


    End Sub
0
Hello Experts,
I there a way to send messages to WhatsApp from my vb net app?
Regards
0
Hello Experts.

I am experiencing a small problem when creating custom user controls from within a given project. Note that this is not a problem when creating a dedicated project for the user control, but sometimes I really don't need the user control to be available for other future projects, and just need it to be available from the specific project.

In searching the web, I find two main "schools" on how to create user controls. Some have you do right from within the project, and others have you create it as a separate project. I'm wondering if perhaps I am missing an important step with the procedure for creating a user control from within the project.

So, in my case, I have an existing project and right-click the project name, and choose Add > User Control. After designing it, I click Build Solution. My current expectation is to find a .DLL file in my bin/debug directory, but it is not there.

I have seen some posts on other forums that reference changing the user control from private to public, but don't really see a way to do this.

Any insights would be appreciated!
0
Hello,
What is the Test option in visual studio 2017 used for.

Regards
0
I am using visual studio 2015.  Asp.net site using VB.net

I am retrieving an amount from a database and I need to have that amount appear on the page with commas.  For example the number is showing as (example) 26012  I need it to show as 26,012

I guess I first need to convert the amount to a string then format the string, but I am not having any luck.  

Thank you
0
Exploring SQL Server 2016: Fundamentals
LVL 12
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Hello Experts.

I've come up with a nice method for embedding multiple child forms via MDI into a parent form using the FlowLayoutPanel object as a container for the various forms.

So on the main menu, the user might click "Show Form 1" and it appears in the MDI parent form. Next the user clicks "Show Form 2" and it would appear below Form 1 and automatically enable the vertical sroll bar so they can navigate between the forms. Finally, the user clicks "Show Form 3" and it appears below Form 2 compliments of the FlowLayoutPanel. The user now has three forms that they can access just by scrolling to the desired form.

THE QUESTION:
How should I handle the process of removing forms from the FlowLayoutPanel? This would typically occur when the user clicks on the Exit control on any of the three forms.
I would also like to have general menu options to close specific forms and another to close ALL forms. Here's what I've come up with so far:
Public Sub CloseForms(ByVal WhichForm As String)
   Dim FormList As New List(Of Control)
   Dim FormCnt As Integer = FormList.Count - 1
   For Each frm As Form In getMyControls(FormList, frmMain.flpMain, GetType(Form))
       Select Case WhichForm
           Case "First"
               If FormList.Item(0) Is frm Then frm.Close()
           Case "Last"
               If FormList.Item(FormCnt) Is frm Then frm.Close()
           Case "All"
               frm.Close()
       End Select
   Next
   GC.Collect()
End Sub

Open in new window


Just to translate the above code, Function getMyControls does this:
    Public Function getMyControls(ByVal ControlList As List(Of Control), ByVal parent As Control, ByVal ControlType As System.Type) As List(Of Control)
        If parent Is Nothing Then Return ControlList
        For Each child As Control In parent.Controls
            Try
                ControlList.Add(child)
            Catch
            End Try
        Next child
        Return ControlList
    End Function

Open in new window


Also, frmMain is the MDI parent form, and flpMain is the FlowLayoutPanel docked inside of frmMain.

The error message that I am receiving is
System.NullReferenceException was unhandled
  HResult=-2147467261
  Message=Object reference not set to an instance of an object.

By the way, I just now tried replacing the line
For Each frm As Form In getMyControls(FormList, frmMain.flpMain, GetType(Form))

Open in new window

with the line
For Each frm As Form In Main.MdiChildren.AsEnumerable

Open in new window

0
LinkButton Class
https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.webcontrols.linkbutton?view=netframework-4.7.2

Hi experts,
I'm using ASP.NET WebForms and Visual Basic

I have a Link Button on the page like this.

<asp:LinkButton ID="LinkButton1" runat="server" CssClass="small" Height="16px" Text="Link Button"></asp:LinkButton>


In the same directory I have a pdf called Test.pdf

When I click on the link button, I want to open the pdf.

What's the best preferred way to set the link on the LinkButton?
0
Hi,

I have this c# sub that I want to convert to vb. The main idea is to take the file contained in the filename and write it to the stream in chunks. It works fine in C# but I can't get it to work in vb.net. This is the version in c#:
 public void WriteFile(Stream stream, string filename)
        {
            using (FileStream readIn = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                readIn.Seek(0, SeekOrigin.Begin); // move to the start of the file
                byte[] fileData = new byte[BufferSize];
                int bytes;
                while ((bytes = readIn.Read(fileData, 0, BufferSize)) > 0)
                {
                    // read the file data and send a chunk at a time
                    stream.Write(fileData, 0, bytes);
                }
            }
        }

Open in new window

And this is two versions I've tried in vb without success. In the first the code jumps over the while loop and doesn't write to the stream and in the second it complains that I can't close before all the bytes are read.

 Public Sub WriteFile(ByRef stream As Stream, ByVal filename As String)
            Using readIn As FileStream = New FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
                readIn.Seek(0, SeekOrigin.Begin)
                Dim fileData As Byte() = New Byte(BufferSize - 1) {}

                Using rdr As New BinaryReader(readIn)
                    'Read BufferSize bytes from the file
                    Dim bytes(BufferSize) As Byte
                    'Dim bytesRead As Integer = rdr.Read(bytes, 0, BufferSize)
                    Dim bytesRead As Integer = 0

                    While ((bytesRead = rdr.Read(bytes, 0, BufferSize)) > 0)
                        stream.Write(bytes, 0, bytesRead)
                    End While
                End Using
            End Using
        End Sub

Open in new window


 Public Sub WriteFile(ByRef stream As Stream, ByVal filename As String)
            Using readIn As New FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
                readIn.Seek(0, SeekOrigin.Begin)
                Using rdr As New BinaryReader(readIn)

                    Using wtr As New BinaryWriter(stream)
                        ' read all bytes
                        Dim bytes() As Byte = rdr.ReadBytes(readIn.Length)
                        ' write all bytes
                        wtr.Write(bytes)

                    End Using

                    rdr.Close()
                End Using

            End Using
        End Sub

Open in new window


If someone can help me get it right I would be grateful.

Peter
0
Hi,
Any suggestions on the answer for if there are many if statement in the code, how to make it more efficient in rewriting the code.
2. If there are too many constants declared at the beginning of the code , how to rewrite it.
3. Any suggestions for concurrency.

Thanks
0
Hello Experts,
I have the content of an XML file being shown in a richtextbox (.NET VB)
How can I make it have the color formatting?
Regards,
0
I have an asp.net application built using vb.net on visual studio 2015.  I want the user to be able to print an asp page to either a printer or Adobe PDF without headers or footers.  I don't want the user to have to adjust the print settings in their browser.  Is there a way I can create a print button that will send the page to a printer and change their header and footer settings to be blank.
0
I'm using visual basic in a ASP.NET web forms page.

In my vb code i have 2 date variables like this the gettodaysdate variable gets the date in this format: 11/28/2018

Dim gettodaysdate As String = String.Format("{0:MM/dd/yyyy}", DateTime.Now)

Dim teststring1 As String
teststring1 = "submitted by website test note 1"

I want to create a variable called teststring2:

I want to add the gettodaysdate variable right after the string "submitted by website" inside teststring1.

So the teststring2 variable should contain this value:

"submitted by website [11/28/2018] test note 1"

What's the syntax for this?
0
Hello Experts,
This is a VB6 very small app that has been working fine for decades
the nice things users like about it are that it shows a percentage number when transmitting... and its pretty fast.

For some reason, it started showing the following message
" 503 This system is not configured to relay sender from an anonymous sender. "

Please your advice,
Regards
_07_VB6-send_mail.rar
0
Hello Experts,
This code gives no error message. Apparently works just fine
But the email sent never arrives.
Please your help

Imports System.Web
Imports System.IO
Imports System.Net.Mail
Imports System.Net.Mail.Attachment
Imports System.Runtime

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    End Sub

    Sub mail()
        On Error Resume Next
        Dim mail As New MailMessage()
        Dim SmtpServer As New SmtpClient
        SmtpServer.Credentials = New Net.NetworkCredential("myemail@gmail.com", "mypassword")
        SmtpServer.Port = 587
        SmtpServer.Host = "smtp.gmail.com"
        SmtpServer.EnableSsl = True
        SmtpServer.EnableSsl = True
        mail.To.Add("someone@hotmail.com")
        mail.From = New MailAddress("myemail@gmail.com")
        mail.Subject = TextBox1.Text
        mail.Body = TextBox2.Text
        Dim myfile As New Attachment("c:\tmp\cdsrita.rar")
        mail.Attachments.Add(myfile)
        SmtpServer.Send(mail)
        MsgBox("Email Send SuccessFully. :)", MsgBoxStyle.Information)
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        mail()
    End Sub
End Class

[Edited by Southmod to remove credentials]
0
JavaScript Best Practices
LVL 12
JavaScript Best Practices

Save hours in development time and avoid common mistakes by learning the best practices to use for JavaScript.

Hello Experts,
I need to send an email with several attachments (min 2 attachments max 10, very small images 500kb ans some .doc )
also ned to use copy to and BCC to several emails ( at least 3 for each field)
could be visual basic or visual c#
I have tried examples in youtube and googling but they all have issues
Please if you can send me, or show me a working example.
Regards,
0
I'm using VB in a ASP.NET Web Forms page.

I have a VB string variable called testvar1

declared like this:

Dim testvar1 As String

sometimes this variable will hold this value.

testvar1 = "submitted by user"

sometimes this variable will hold this value

testvar1 = "submitted by user bsmith"

sometimes this variable will hold this value

testvar1 = "submitted by user bjackson"


What's the syntax in a if else statment to look at the variable testvar1
and if there is any text after this text "submitted by user" then set variable True otherwise set it false

So far I have this but how do I look at the string inside the variable testvar1 and determine if it contains any text after the word submitted by user.


                    If ( ) Then
                       ' if there is any text after this string submitted by user in the variable testvar1 set variable checkvariable to true
                       checkvariable = True
                    Else
                        checkvariable = False
                    End If
0
Hi,
Any suggestions for VB.Net interview questions.

Thanks
0
Hi,
How do you explain a approach for a vb.net desktop project.
If asked to explain a project and a methodology, any suggestions on how to explain.
Example: I have used classes etc.

Regards
0
Hi Experts,

I faced a database query issue ... I tried to solve it myself (I'm using VB.Net  VS 2015)but my solution i think that is not perform the mission well ...OK

I have a product put in more than one partition "say 2 partitions" (it must be more than 2 partitions)these partitions filled with the products as follow ...

product1  ==>>(partition1 =  5 pieces) and (partition2 =  1 pieces)   and total pieces of  product1 = 6 pieces...... and
product2  ==>>(partition10 =  1 pieces) and (partition15 =  0 pieces) and (partition3 =  0 pieces) and total pieces of  product2 = 1 piece
product3  ==>>(partition10 =  0 pieces) and (partition2 =  1 pieces) and (partition1 =  0 pieces) and total pieces of  product3 = 1 piece
product4  ==>>(partition2 =  2 pieces) and (partition3 =  1 pieces)   and total pieces of  product4 = 3 pieces
 The question is how to query in my database to find if the (total pieces of  specific product) became =1 piece
in order to make a report of the products that decreased and need to purchase  



I think this photo is enough to indicate my needs ... The blue line indicates that ProductCode '6' has 3 partitions and total pieces = 4
The Red line indicates that ProductCode '8' has 2 partitions and total pieces = 1               ........................
when i made a query on 'StockNo' in the database  i get all 'StockNo' that have 1 piece not the total pieces of   'StockNo'  for specific product code.

Any Suggestions…
0
Hi, I'm looking for a general reference on constructing and using a config file for a Windows application -- I'm especially interested in syntax and how the file is parsed. Assume I know nothing but know how to code -- my experience has primarily been with SQL-based DBs so I'm used to storing my values there, but dropping and using a small config file seems like an easier approach for the VB-based app I'm constructing now. Security is also a consideration.
0

Visual Basic.NET

93K

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,