Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x

Visual Basic.NET

92K

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

Hello,
How can i convert this functon compatible to listview
 Private Sub ListBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles ListBox1.MouseDown
        If e.Button = MouseButtons.Left Then
            Dim pt As New Point(e.X, e.Y)
            startIndex = ListBox1.IndexFromPoint(pt)

            If startIndex >= 0 Then
                Dim itemRc As Rectangle = ListBox1.GetItemRectangle(startIndex)
                startPoint = ListBox1.PointToScreen(New Point(ListBox1.Width, itemRc.Top + (itemRc.Bottom - itemRc.Top) / 2))
                endPoint = startPoint
                lastIndex = -1
                ListBox1.DoDragDrop(ListBox1.Items(startIndex).ToString(), DragDropEffects.Move)
            End If
        End If
    End Sub

Open in new window



  Private Sub ListBox2_DragOver(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragOver
        Dim lbPoint As Point = ListBox2.PointToClient(New Point(e.X, e.Y))
        Dim index As Integer = ListBox2.IndexFromPoint(lbPoint)
        If index >= 0 Then
            ListBox2.SelectedIndex = index
            Dim itemRc As Rectangle = ListBox2.GetItemRectangle(index)
            Dim key As String
            If lastIndex <> index Then
                If lastIndex <> -1 Then
                    key = startIndex & "|" & lastIndex
                    If Not connections.ContainsKey(key) Then
                        ControlPaint.DrawReversibleLine(startPoint, endPoint, Panel1.BackColor)
                    End If
                End If
                key = startIndex & "|" & index
                If Not connections.ContainsKey(key) Then
                    endPoint = ListBox2.PointToScreen(New Point(0, itemRc.Top + (itemRc.Bottom - itemRc.Top) / 2))
                    ControlPaint.DrawReversibleLine(startPoint, endPoint, Panel1.BackColor)
                End If
                lastIndex = index
            End If
        End If
    End Sub

Open in new window


  Private Sub ListBox2_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles ListBox2.DragDrop
        Try

            Dim endIndex As Integer = ListBox2.IndexFromPoint(ListBox2.PointToClient(New Point(e.X, e.Y)))
            If endIndex >= 0 Then
                connections.Add(startIndex & "|" & endIndex, Nothing)
            End If
            Panel1.Refresh()
        Catch ex As Exception
            Exit Sub
        Finally
            Panel1.Refresh()
        End Try

    End Sub

Open in new window


ListBox2.GetItemRectangle(index)
GetitemRectangle,IndexFromPoint is not a part of listview
0
On Demand Webinar: Networking for the Cloud Era
LVL 10
On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Hello,
Need some advice on how to create a program that can draw data model?
This works but,need to use datagridview
https://www.experts-exchange.com/questions/21540913/Need-some-advice-on-how-to-create-a-program-that-can-draw-data-model.html


Any suggestions are appreciated.

Cheers
0
Hello,
How can I have a multicolumn bound listbox .
Bound to datatable
I am using vb.net desktop.
0
I added references from http://vb.net-informations.com/files/create-pdf.htm to my vb.net program.  I have no problem creating a PDF document, but I'm trying to figure out how to change the orientation to landscape.

I tried this...
Dim pdfPage As PdfPage = pdf.AddPage.Orientation.Landscape

Open in new window


and this...
pdfPage.Orientation.Landscape

Open in new window


But neither work.  I get the options of Orientation and Landscape from auto-fill, so I know it must be possible, but I get an error in the error list saying that PageOrientation cannot be converted to pdfPage.  How do I set the orientation?
0
Hi Experts,

I am generating some labels as shown in Label1.png. My design is in Labeldesign.png.  My client needs the output in two columns as shown in Label_Desired.png. Please suggest is there any way to do it?

Thanks in advance.
Label1.png
LabelDesign.png
Label_Desired.png
0
Hi all, after select data from a combobx and save
i want to make it readonly as a textbox,
i only find the option enabled=false for achive that but the text is so blur
how to made a combobox read only
regards!
0
So I added the references here...
http://vb.net-informations.com/files/create-pdf.htm
For creating a PDF document in vb.net.  This works fine, but in my code, I don't know how to start a new line.  I tried using Evironment.NewLine, but it doesn't advance beyond the first line of text.  I'm sure the issue is that I can't keep using "TopLeft", but I can't figure out how to write multiple lines to the page.  Here's my code:

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim pdf As PdfDocument = New PdfDocument
        pdf.Info.Title = "Renewal Report"
        Dim pdfPage As PdfPage = pdf.AddPage
        Dim graph As XGraphics = XGraphics.FromPdfPage(pdfPage)
        Dim font As XFont = New XFont("Consolas", 20, XFontStyle.Regular)
        '// Writing first line
        graph.DrawString("First Line of Document", font, XBrushes.Black,
        New XRect(0, 0, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)
        '// Trying to add new line
        graph.DrawString(Environment.NewLine, font, XBrushes.Black,
        New XRect(0, 0, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)
        '// Trying to write second line
        graph.DrawString("Second Line of Document", font, XBrushes.Black,
        New XRect(0, 0, pdfPage.Width.Point, pdfPage.Height.Point), XStringFormats.TopLeft)
        Dim pdfFilename As String = "firstpage.pdf"
        pdf.Save(pdfFilename)
        

Open in new window

0
Troubleshooting a piece of code.
            Dim web As Net.WebClient = New Net.WebClient()
            Dim html As String = web.DownloadString("https://www.google.com/finance/converter?a=1&from=EUR&to=USD")
            Dim m1 As Match = Regex.Match(html, "<span class=bld>\s*(.+?)\s*</span>", RegexOptions.Singleline)
            Dim currency As String = m1.Groups(1).Value.Replace("USD", "")

            user.setEuro(Convert.ToDouble(currency))

Open in new window

currency is blank.  

My question is what does "<span class=bld>\s*(.+?)\s*</span>", RegexOptions.Singleline" do?
0
Hello, i am creating an application in which i need to generate invoice! i have four different tables from which data is coming to print the invoice! i am using access database! my problem is that when the report gets loaded in the details section of the report it shows same records many times!
i have two tables bill details and bill particulars! bill details stores all the details like bill id, date, time, customer name, sub total, gst, discounts and grand total! the bill particulars table saves the products to be added under the bill so it has product id, qty, total amt
so if i have only one product under a bill the report shows the product once
if i have two products under bill then in report i get the entry of both products twice
and so on...
how to fix this?
0
Hi,

How do I prevent users from resizing a Form by dragging its border using VB.NET?

Kind regards,

Victor
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE
LVL 4
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

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

I've tried theses code but these isn't working, please help me T_T

Dim st As String = "Update OrderItems set Item=@item,Price=@price where ID=@id"
        Dim cmd As New SqlCommand(st, con)

        Try

            If cmd.Connection.State = ConnectionState.Open Then cmd.Connection.Close()
            con.ConnectionString = connection
            cmd.Connection.Open()
            cmd.Parameters.AddWithValue("@item", txtitem.Text.Trim)
            cmd.Parameters.AddWithValue("@price", txtprice.Text.Trim)
            cmd.Parameters.AddWithValue("@id", txtid.Text.Trim)

            If cmd.ExecuteNonQuery > 0 Then
                MsgBox("Updated Successfully", MsgBoxStyle.Information)
                txtitem.Clear()
                txtprice.Clear()
                txtid.Clear()
                txtitem.Focus()

            End If

        Catch ex As Exception
            MsgBox(ex.Message)
        Finally
            cmd.Connection.Close()

        End Try
0
Hi,



I have two tables created from 2 xml files which are linked by the NSC column, How do I create a new table with data from table2 by merging data from table2 to table1, where the fields from table2 are included in table1, for example if table1 contains

NSC:   F1                            F2

1         AGD, AGD1            AGD

2        AGD                        AGD, AGD1



table2 contains:

NSC:   AGD   AGD1

1         XXX    YYY

2        ZZZ    WWW



How do I create table3?



NSC:   F1                            F2

1         XXX;YYY                XXX

2        XXX                        XXX;YYY


Thanks,

Victor
0
An employee is filling leave application form, mentions leave start date and end date. I have following on my .aspx form :

 
Label(Leave starts Date), text box, calendar extender (with format set to dd/mm/yyyy), required field validator


Label(Leave End Date), text box, calendar extender (with format set to dd/mm/yyyy), required field validator

Compare Validator
to ensure Start Date is not less than end date.



      <div class="form-group">
            <label>Leave starts Date</label>
            <asp:TextBox runat="server" ID="txtDurationFrom" CssClass="form-control" AutoPostBack="true" />
            <cc1:CalendarExtender ID="txtDurationFrom_CalendarExtender" runat="server" TargetControlID="txtDurationFrom"  Format="dd/MM/yyyy" > 
            </cc1:CalendarExtender>

            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Enter Starting Date of Leave Period" ControlToValidate="txtDurationFrom" >
            </asp:RequiredFieldValidator>
 

            <label>Leave End Date</label>
            <asp:TextBox runat="server" ID="txtDurationTo" CssClass="form-control" AutoPostBack="true" />
            <cc1:CalendarExtender ID="txtDurationTo_CalendarExtender" runat="server" Enabled="True"
            TargetControlID="txtDurationTo" Format="dd/MM/yyyy" >
            </cc1:CalendarExtender>

            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Enter Last Date of Leave Period"
            ControlToValidate="txtDurationTo">
            </asp:RequiredFieldValidator>
   
 
            <asp:CompareValidator  …
0
I'm trying to print form, but the controls not shown on the form. the form have only textboxes and picturebox.

I have this code work fine but unfortunately when the form shown in the printpreviewdialog the the picturebox appears but textboxes not.

any one can help me where is the wrong.

this is the code:

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Me.PrintDocument1.PrinterSettings.DefaultPageSettings.Margins = New Printing.Margins(0, 0, 0, 0)
    Me.PrintPreviewDialog1.Document = Me.PrintDocument1
    Me.PrintPreviewDialog1.WindowState = FormWindowState.Maximized
    Me.PrintPreviewDialog1.ShowDialog()

End Sub

Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
    e.Graphics.DrawImage(GetFormImage, New Point(0, 0))

End Sub

Private Function GetFormImage(Optional ByVal include_borders As Boolean = False) As Bitmap
    ' Make the bitmap.
    Dim wid As Integer = Me.Width
    Dim hgt As Integer = Me.Height
    Dim bm As New Bitmap(wid, hgt)

    ' Draw the form onto the bitmap.
    Me.DrawToBitmap(bm, New Rectangle(0, 0, wid, hgt))

    ' If we want the borders, return the bitmap.
    If include_borders Then Return bm

    ' Make a smaller bitmap without borders.
    wid = Me.ClientSize.Width
    hgt = Me.ClientSize.Height
    Dim bm2 As New Bitmap(wid, hgt)

    ' 

Open in new window

1
I am implementing paypal payment into my vb.net project using javascript payment system.

I want to schedule payment. For example- I want to enable user to schedule payment in future.

How can i do this?

Please suggest.
0
Hi,


I am using the code below to copy data from file2 to file1 in matching fields based on identical NSC, How do I modify it to copy  field values from file1 to file2 based on identical NSC and if field exist in file2 than save results to file3.xml?

        ' ' Load the file1.xml and file2.xml into memory
        Dim f1 = XDocument.Load(Application.StartupPath + "\file1.xml")
        Dim f2 = XDocument.Load(Application.StartupPath + "\file2.xml")

        '' Query both documents and Join on the NSC node in each 
        Dim results = From n1 In f1.Descendants("Table1") _
                     Where n1.Element("NSN") IsNot Nothing _
         From n2 In f2.Descendants("Table2") _
         Where n2.Element("NSC") IsNot Nothing AndAlso n1.Element("NSC").Value = n2.Element("NSC").Value _
        Select n1, n2

        '' Copy the elements from File2 to File1
        For Each pair In results
            Dim removeNSC = pair.n2.Element("NSC")
            removeNSC.Remove()
            For Each element As XElement In pair.n2.Descendants()
                pair.n1.Add(element)
            Next
        Next
        '' Save file1.xml as file3.xml
        f1.Save(Application.StartupPath + "\File3xml")

Open in new window

If file1.xml contains

<Root>
<Table1>
<NSC>1</NSC>
<A>Value1</A>
<B>Value2</B>
<C>Value3</C>
<D>Value4</D>
</Table1>
<Table1>
<NSC>2</NSC>
<A>Value1a</A>
<B>Value1b</B>
<C>Value1c</C/>
<D>Value1d</D>
</Table1>
<Table1>
<NSC>3</NSC>
<A>Value1e</A>
<B>Value1f</B>
<C>Value1g</C>
<D>Value1h</D>
</Table1>
</Root>

Open in new window

and fil2.xml contains:

<Root>
<Table1>
<NSC>1</NSC>
<F1>A</F1>
<F2>A,B</F2>
<F3>B,C</F3>
<F4>A,B,C,D</F4>
<F5>B,C</F5>
<F6>A,D</F6>
</Table1>
<Table1>
<NSC>6</NSC>
<F1>C</F1>
<F2>A,B,D</F2>
<F3>B</F3>
<F4>C,D</F4>
<F5>B,C</F5>
<F6>A,D</F6>
</Table1>
</Root>

Open in new window

How do I copy values from file1.xml to file2.xml based on identical NSC, separate the values by a semicolon and save the results in file3.xml using VB.NET?

File3.xml

<Root>
<Table1>
<NSC>1</NSC>
<F1>Value1</F1>
<F2>Value1;Value2</F2>
<F3>Value2;Value3</F3>
<F4>Value1;Value2;Value3;Value4</F4>
<F5>Value2;Value3</F5>
<F6>Value1;Value4</F6>
</Table1>
</Root>

Open in new window

0
How to display the size of tblmountertrace_1 (to) 9 to text box? Please see picture:

database table
Im using this code but I dont know how to query. I put it on the Timer (timSERVERSIZE) to update every 4 Hours a day.

        Private Sub timSERVERSIZE_Tick(sender As Object, e As EventArgs) Handles timSERVERSIZE.Tick
        Dim cmd2 As New MySqlCommand
        Dim myDA2 As New MySqlDataAdapter(cmd2)
        Dim myDT2 As New DataTable
        cmd2.Connection = conn
        cmd2.CommandText = "SELECT * FROM esd_reco ?????????????????????????????????????"
        myDA2.Fill(myDT2)
        TextBox1.items.add(myDA2)  <<<<<<<<<<<<??????????????????????????


    End Sub

Open in new window


Thanks for the help
0
I have an aspx page that runs a stored proc. The stored proc returns a value ( a record ID) after performing a few insert statements.  I want to get that return value with vb code.  My current code (see * below) gets an error message: "Input string was not in a correct format."  I can't find the right code to get the return value.  What is the flaw(s) in my code?

Thanks for looking.

The stored proc:
CREATE PROCEDURE [dbo].[CreateEval]
	    @EmployeeNumber int
	  , @EmpLastName varchar(30)
	  , @EmpFirstName varchar(30)
	  , @EmpDepartmentID int
	  , @EmpJobTitleID int
	  , @SupervisorID int
	  , @SupLastName varchar(30)
	  , @SupFirstName varchar(30)
	  , @SupervisorDeptID int
	  , @SupervisorTitleID int
	  , @EvalID int = NULL OUTPUT
AS

BEGIN
	/*some inserting happens here		
END

BEGIN
	/*some inserting happens here		
END

BEGIN
	INSERT INTO EvalHeader
		(EmployeeNumber
	   , SupervisorID
	   , EvalDate)
	VALUES (@EmployeeNumber
		  , @SupervisorID
		  , GETDATE())
	SET @EvalID = SCOPE_IDENTITY()
	
	INSERT INTO EvalScoring
		(EvalID)
	VALUES (@EvalID)
	RETURN 
END

Open in new window


Here is the sql data source:
<asp:SqlDataSource ID="dsCreateEval" runat="server" ConnectionString="<%$ ConnectionStrings:EmpEval_TestConnectionString %>" SelectCommand="CreateEval" SelectCommandType="StoredProcedure"
        InsertCommand="CreateEval"
        InsertCommandType="StoredProcedure">
        <InsertParameters>
            
            <asp:ControlParameter 

Open in new window

0
Hi,
I am currently using Infopath 2013 which is connected into a SQL server Db, My Infopath Form has three fields:

Start_Time - DateTime
Stop_Time - DateTime
Duration - Integer

I am having trouble referencing these fields in visual studio using VB as it doesn't seem to recognise these as actual fields within the Infopath Form as the Duration field just stays blank with no errors?

Basically i'm looking to do this as an After Change event set on Stop_Time:

Duration = DateDiff("s", Start_Time, Stop_Time)

Open in new window


Very very basic VB knowledge here so any help you can give me will be much appreciated.
0
Concerto's Cloud Advisory Services
LVL 4
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

I want to use the following C# code in a VB program.  How would I convert this?  The first line seems to just be a matter or removing the semicolon, but I can't test it since I am unable to figure out the second line.
textbox1.Select( textbox1.GetFirstCharIndexFromLine( 0 ), textbox1.GetFirstCharIndexFromLine( 1 ) - textbox1.GetFirstCharIndexFromLine( 0 ) );
textbox1.SelectionFont = new System.Drawing.Font( "Tahoma", 10, FontStyle.Bold );

Open in new window

0
how do i create a string variable with a date like this MMDDCCYY?

I am going to use that to name a field later
0
Hello,
How can I Draw line from datagridview1 cell to another datagridview2 cell.
Just want to show a connection.
I am using vb.net desktop.

Thanks
0
Hi, any help please with this problem.
I used this code
Dim chos2 As String
        chos2 = Val(TextBox2.Text) & ".jpg"
        PictureBox3.ImageLocation = "file://192.168.6.252/pasa/esdcheck/res_pic/" & chos2

Open in new window

But when I remove credential to that computer the image does not appear, I need a code to programatically enter the "user" and "password"
Like SQL, This code works:
conn.ConnectionString = "server=192.168.6.252;userid=user;password=123!@#;database=msd"

Open in new window

But how to do that with the computer users and password?

If I enable/check the remember my credential, the user of the program can also access the shared folders of the computer w/ PI 192.168.6.252, or the server let's say,. I want to restrict that, Please any help.

Thanks
0
Hi,

If file1.xml contains

<Root>
<Table1>
<NSC>1</NSC>
<A>Value1</A>
<B>Value2</B>
<C>Value3</C>
<D>Value4</D>
</Table1>
<Table1>
<NSC>2</NSC>
<A>Value1a</A>
<B>Value1b</B>
<C>Value1c</C/>
<D>Value1d</D>
</Table1>
<Table1>
<NSC>3</NSC>
<A>Value1e</A>
<B>Value1f</B>
<C>Value1g</C>
<D>Value1h</D>
</Table1>
</Root>

and fil2.xml contains:

<Root>
<Table1>
<NSC>1</NSC>
<F1>A</F1>
<F2>A,B</F2>
<F3>B,C</F3>
<F4>A,B,C,D</F4>
<F5>B,C</F5>
<F6>A,D</F6>
</Table1>
<Table1>
<NSC>6</NSC>
<F1>C</F1>
<F2>A,B,D</F2>
<F3>B</F3>
<F4>C,D</F4>
<F5>B,C</F5>
<F6>A,D</F6>
</Table1>
</Root>

How do I copy values from file1.xml to file2.xml based on identical NSC, separate the values by a semicolon and save the results in file3.xml using VB.NET? This is just an example the projects contains multiple records in both xml files and many cases the NSC values will not match.

File3.xml

<Root>
<Table1>
<NSC>1</NSC>
<F1>Value1</F1>
<F2>Value1;Value2</F2>
<F3>Value2;Value3</F3>
<F4>Value1;Value2;Value3;Value4</F4>
<F5>Value2;Value3</F5>
<F6>Value1;Value4</F6>
</Table1>
</Root>

Thanks,

Victor
0
I'm using this code to print form, but I want the printpreviewdialog to start in maximized state, how can I do this ??

I fined this code on another post here in the site :
  DirectCast(PrintPreviewDialog1, Form).WindowState = FormWindowState.Maximized

Open in new window


but I'm not using the control PrintPreviewDialog1 so please help.

   
 PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
    PrintForm1.PrinterSettings.DefaultPageSettings.Margins = New Printing.Margins(0, 0, 0, 0)
    PrintForm1.Print()
 

Open in new window

0

Visual Basic.NET

92K

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,