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

Dear Experts,

Can anybody help me to sort out the issue?

Issue Description : I need to get the textbox entered value in gridview at the time of linkbutton click event.

Design Page :
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="prefLine"
                                                    AllowPaging="True" AllowSorting="True"
                                                    OnPageIndexChanging="GridView1_PageIndexChanging" Width="100%" BackColor="White" BorderColor="#999999" EnableModelValidation="True" GridLines="Vertical">
                                                    <Columns>
                                                        <asp:TemplateField HeaderText="Edit" >
                                                            <ItemTemplate>
                                                                <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#String.Format("frmSls.aspx?id={0}&det={1}", HttpUtility.UrlEncode(Eval("nSlsID").ToString()), HttpUtility.UrlEncode(Eval("nSlsDetID").ToString())) %>'
                                                                    Text="Edit" CommandName="select">
                                                                </asp:HyperLink>
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        

Open in new window

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.

Hi all. I have a windows form created in vb.net (visual studio 2013) that is displaying the following error:

Conversion from type 'DBNull' to type 'Decimal' is not valid

In the following code:
Dim frm As New ContractEditItem
 frm.stdcost = DataGridDetails.SelectedRows(0).Cells("StdCost").Value

Open in new window


When the StdCost cell in the DataGridDetails datagrid is null. The StdCost cell is of type Decimal and the frm.stdcost variable is also of type Decimal.

There are times when records do not have a stdcost and there are times when it does.

First question: How can I fix this error?
Second question: There may be times when the end user will do some changes to some other fields and then click a Save button which will insert records into a table and the stdcost field may be null and this is ok for our systems, will I also get an error when that happens?

Thank you in advance.
0
Hey I am working on a Windows App in Vb.net where I load a Dropdown box and a Listview with Printers from a Printserver.
I can do this if it were pulling data from a database but  the goal is to type in dropdown the Printername and dropdown autocompletes like a Google Search My Challenge is when dropdown is selected I want listview to filter to the name in dropdown.
Here is the visyuals and code. I don't know how to sort to printer in listview.
Printer App with dropdown wanting to sort to the desired Printer NAMEHere are the Print names next to Icon of Printer
Print App displaying all the Printers.
  Public Sub Printers()
        Dim options As ConnectionOptions
        options = New ConnectionOptions
        options.Username = "xxxxxx"
        options.Password = "xxxxxxxxxxxx"
        LSPrinters.Clear()
        '* Test the connection


        '  Dim ps() As Services
        LSPrinters.BeginUpdate()

        LSPrinters.Columns.Add("", 150, HorizontalAlignment.Center)
        LSPrinters.Columns.Add("Name", 150, HorizontalAlignment.Left)
        LSPrinters.Columns.Add("DriveName", 250, HorizontalAlignment.Left)
        LSPrinters.Columns.Add("Location", 250, HorizontalAlignment.Left)

        LSPrinters.Columns.Add("Port Name", 200, HorizontalAlignment.Left)
        ' LSPrinters.Columns.Add("Document", 150, HorizontalAlignment.Left)
        ' LSPrinters.Columns.Add("Jobstatus", 150, HorizontalAlignment.Left)
        '' LSPrinters.Columns.Add("PagesPrinted", 150, HorizontalAlignment.Left)
        ' 

Open in new window

0
Hey

How do I connect to a SQL server - and return a recordset? (Trusted_Connection=True)

For example (Select * from mytable where field1=1)

Using VB.NET

Thanks in advance

Mike
0
Hello,
How to export a datable as a url. The displayed web form should have the datatable in the form of a table.
 Thanks
0
Hello,
How can I connect to a stored procedure and display its content on a web page which is desktop/ mobile friendly in a tabular form.
Regards
0
Hello Experts,
We have this very small visual basic .net application that has been working ok for years.
now all of a sudden we get the error


System.Runtime.InteropServices.COMException: 'Unknown error.'

when executing the
Private Sub InitializeComponent()
   ...
  ....
 ....
        Me.Text = "test Web Browser"
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox1.PerformLayout()
        CType(Me.wb, System.ComponentModel.ISupportInitialize).EndInit()  <<< <<<<<<<<<<<<<<<<<<<<<<here
        Me.ResumeLayout(False)   ' DEBUG
        Me.PerformLayout()
end sub

this has never been a problem,
Please your advice on this
0
Hello everybody, I'm a beginner of VB.net and I face this problem ....
how data grid view on click display a data of another table that doesn't link to it..the 2 pictures indicate the problem obviously.
i'm using MS Access 2013 as a database
thanks in advance.................................
2.png
3.png
0
Hello,
I have a code which works perfectly to find and replace but, how can I avoid repetition.
  Dim FindObject As Word.Find = oDoc.Content.Find
            With FindObject
                .ClearFormatting()
                .Text = "«" & "Dr" & "*»"
                .Replacement.ClearFormatting()
                .Replacement.Text = ""
                .Forward = True
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchWildcards = True
                .MatchSoundsLike = False
                .MatchAllWordForms = False '
                .Execute(Replace:=Word.WdReplace.wdReplaceAll)
            End With

            With FindObject
                .ClearFormatting()
                .Text = "«" & "Mo" & "*»"
                .Replacement.ClearFormatting()
                .Replacement.Text = ""
                .Forward = True
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchWildcards = True
                .MatchSoundsLike = False
                .MatchAllWordForms = False '
                .Execute(Replace:=Word.WdReplace.wdReplaceAll)
            End With
            With FindObject
                .ClearFormatting()
                .Text = "«" & "Ve" & "*»"
                .Replacement.ClearFormatting()
                .Replacement.Text = ""
                .Forward = True
                .Format = False
           

Open in new window

0
I have passed string from vb variable to crystalReport TextObject, and when i create a formula and browse for that TextObject to calculate ,it's not available to calculate, how can this done?

Thanks in advance.
0
Technology Partners: We Want Your Opinion!
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

I Need some help with Visual Studio, I have a project file that was made in VS2008 and I need it to work in a newer version (2012)
0
In my .net c# project I have two jason like this

Json1
{"WindowsServices":[{"name":"SNMP","statusID":"1","StatusMsg":"Stopped","FullStatus":"SNMP,1"},{"name":"SNMPTRAP","statusID":"1","StatusMsg":"Stopped","FullStatus":"SNMPTRAP,1"}]}

Open in new window


Json2
{"WindowsServices":[{"name":"SNMP","statusID":"4","StatusMsg":"Running","FullStatus":"SNMP,4"},{"name":"SNMPTRAP","statusID":"1","StatusMsg":"Stopped","FullStatus":"SNMPTRAP,1"}]}

Open in new window


I need to compare this to json and get the result of the modified part oly
{"WindowsServices":[{"name":"SNMP","statusID":"4","StatusMsg":"Running","FullStatus":"SNMP,4"}]}

Open in new window



Thank you for your help!!
0
How can I add a clickable button event on a text box. I want to be able to have the end user enter information into a text box then have them double click the box and I would use a dynamic sql statement in vb.net to update the database with the info they entered in the text box.
0
am not sure why this isn't working but I have a Winform Powershell script that features a function that has a OpenFileDialog element so a user clicks a button and will be able to browse to a file that saves to a variable.
The script works fine if run like a normal powershell script, however when I use PS2EXE to convert it to an exe, it does not open.
If I remove the if/else clause from the function, the exe will open properly after I convert it.


function Get-FileName($initialDirectory)
{
    [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null

    $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
    $OpenFileDialog.title = "Please select a report"
    $OpenFileDialog.initialDirectory = "G:\Departments\Marketing\CSV_Reports"
    $OpenFileDialog.filter = "CSV (*.csv)| *.csv"
    #$OpenFileDialog.ShowDialog() | Out-Null
    $result = $OpenFileDialog.ShowDialog()


if($result -eq “Ok”) {

$script:newFileName = $OpenFileDialog.filename
$script:RefundFile = Get-ChildItem $newFileName
$script:fileLocation = $RefundFile | select -ExpandProperty versioninfo | select -ExpandProperty FileName
$script:fileFolder = Split-Path $fileLocation
$fileDetails_FileName.Text = $RefundFile.name
$fileDetails_FileLastCreated.Text = $RefundFile.CreationTime
$fileDetails_FileLastModified.Text = $RefundFile.LastWriteTime
$fileDetails_FileFolderLocation.Text = $fileLocation

}

else {
Write-Host “Cancelled by user"

}    

Open in new window


So the purpose if the If/Else is so that a file is actually selected, otherwise hitting cancel would just pass a wrong variable over.
But it just doesn't allow the .exe of this script to open properly.
0
Hello,
I am doing a mailmerge and need to find part of a word in the document and the replace the whole word.
Example:

   
            Dim FindObject As Word.Find = oDoc.Content.Find
            With FindObject
                .ClearFormatting()
                .Text = "«" & "Dr" & "*"
                .Replacement.ClearFormatting()
                .Replacement.Text = ""
                .Forward = True
                .Format = False
                .MatchCase = False
                .MatchWholeWord = False
                .MatchWildcards = True
                .MatchSoundsLike = False
                .MatchAllWordForms = False '
                .Execute(Replace:=Word.WdReplace.wdReplaceAll)
            End With

Open in new window


Cheers
0
I am seeing double boxes on my web form grid on some fields.
It is definitely the data because If I load the data value into a label  it shows the same way.

vb.Net web forms .Net 4.5
MS SQL Server 2012 database

You can see the boxes below in ALL the email addresses and one of the last names.
How can I trim this?

We have tried LTRIM and RTRIM

And the data is coming in from a service with varname.ToString().Trim()

SP
0
Hello,
How can i merge excel template with telerik radgrid.
i am using vb.net desktop.

Regards
0
Hello Experts.

I've been wanting to a add a really nice looking pop-up that shows temporarily for a set number of seconds then doesn't show again while the program is running. I'm only able to get it to partially show on the screen. The fantasy was to have something that floats up then goes away, but that's more of a WPF thing and I am only working with a basic Windows Form. I'm thinking perhaps the System.Threading.Thread.Sleep function is causing the problem, but I'm not sure how else to do this.

To help with understanding my issue, I have created a quick Demo solution that should suffice for its purpose. Please note that I still don't have WinZip, so the attached file is actually a .RAR file renamed to have a .ZIP extension so the EE uploader would take it.

BTW, I found a pretty decent solution that also uses System.Threading.Thread.Sleep but it uses the MsgBox function, and not a custom form which is what I want to do. Nevertheless, it does work. This is the code for that solution. If we can just swap out the standard dialogue with mine, that would be great!

Module FormUtils
    Private sAutoClosed As Boolean
    Private Sub CloseMsgBoxDelay(ByVal data As Object)
        System.Threading.Thread.Sleep(CInt(data))
        SendKeys.SendWait("~")
        sAutoClosed = True
    End Sub
    Public Function MsgBoxDelayClose(prompt As Object, ByVal delay As Integer, Optional buttons As MsgBoxStyle = MsgBoxStyle.ApplicationModal, Optional title As 

Open in new window

0
The following is my code to measure the text width in a picture box and it works fine

Dim fontToMeasure As New Font("Microsoft Sans Serif", 14, FontStyle.Bold)
TextWidthIs = PictureBox1.CreateGraphics.MeasureString(TextLineIs, fontToMeasure).Width.ToString

The problem is that when I want to change the font from inside a loop e.g.

Dim fontToMeasure As New Font("Microsoft Sans Serif", 14, FontStyle.Bold)
For I=1  to 2
    if I=1 then (I want the font to be arial,16,normal)
    if I=1 then (I want the font to be Microsoft Sans ,14,bold)
   TextWidthIs = PictureBox1.CreateGraphics.MeasureString(TextLineIs, fontToMeasure).Width.ToString
next

Any Idea?
0
Ready to get started with anonymous questions?
LVL 9
Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Hi All i have this file which i want to convert to csv very simple i just need all the columns.

Account Number  &  Name                   Telephone No.   Contact          Credit Limit               Last Cash  Branch/Ref/Type   Date   Due Date Order Number             Current      30-Days      60-Days      90-Days     120-Days     150-Days   STE  Balance                 Unapplied

I have attached the file.

Thank you for your help
AR070717.txt
0
Hi Experts,

I want to display the "number" with "Unit"  for ex. 12 oz. I am using the expression "=Fields!AdjustedPan.Value & Fields!Unit.Value" on that textbox. It displays 12oz. I need and space in between. So I tried ""=Fields!AdjustedPan.Value & "  " & Fields!Unit.Value". But It does not work. What can I do to give a space between the number and the unit. Also need a "." at the end( Like 12 oz.) .

Thanks in advance.
0
I have an enum like so:

Public Enum DataCalls
        GetTypedTable = 0
        Duplicate_Name_Check = 1
        Regular_Table = 2
        Second_Table = 3
        Third_Table = 4
        Template_Load = 5
    End Enum

These values represent function names. Enum 1 is function that returns as boolean. The rest are functions that return as datatables.

I am trying to craft a function that will allow me to cast these enum values and call their respective function.

This is wrong but...

Function Test(ByVal DataCall As String) As Object
        'How do we call the associated
        Dim number As Integer = [Enum].Parse(GetType(clData.DataCalls), DataCall)
        'we have its integer. With this information how do we call the function

    End Function

Second Question. If the function has parameters in this situation, how would you handle that?
0
All,
  I'm using VS 2015 Enterprise, specifically vb.net along with crystal reports.
I have a form1.vb that opens mysql database, asks user for start date & end date & lastly creates xml schema of requested data.

Imports MySql.Data.MySqlClient
Imports System.Text.RegularExpressions

Public Class Form1
    Dim myData As New DataSet
    Dim conn As New MySqlConnection
    Dim cmd As New MySqlCommand
    Dim myAdapter As New MySqlDataAdapter

    Public MySQLConnectionString As String = "server= www.automatedanswers.com;user id=russemi2_test;password=Passw0rd;database=russemi2_test"
    Dim connStr As String = MySQLConnectionString
    Dim sql As String
    Dim id As String
    Dim datetime, datetime2 As String

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim pattern As String = "^(20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])$"
        Dim regex As New Regex(pattern)
        datetime = ""
        datetime = InputBox("Start Date - Use Format 'yyyy-mm-dd'")
        Do While Not regex.IsMatch(datetime)
            datetime = ""
            datetime = InputBox("Start Date - Use Format 'yyyy-mm-dd'")
        Loop


        datetime2 = InputBox("End Date - Use Format 'yyyy-mm-dd'",, datetime)
        Do While Not regex.IsMatch(datetime2)
            datetime2 = ""
            datetime2 = InputBox("End Date - Use Format 'yyyy-mm-dd'")
        Loop

        datetime2…
0
Hello

I'm currently trying to write a simple tool that creates a series of simple buttons that open various system tools.  Using the Process.start option and I'm experiencing a file not found issue when the commands are run.  Currently I'm using the script below to open up for programs as a test.  The first two commands work fine (compmgmt.msc, eventvwr.msc) but the system errors with an Exception Unhandled System.ComponentModel.Win32Exception 'The system cannot find the file specified' when it tries to run dsa.msc.  I've googled it but not found much help, the .msc are definitely in that folder and I can run them from file explorer by double-clicking on them or from a command/PowerShell prompt.   I'm a complete novice with vb.net and most programming, so any light that can be shed on this issue would be gratefully received.

Private Sub ADUC_Click(sender As Object, e As EventArgs) Handles ADUC.Click
        System.Diagnostics.Process.Start("c:\windows\system32\compmgmt.msc")
        System.Diagnostics.Process.Start("C:\Windows\System32\eventvwr.msc")
        System.Diagnostics.Process.Start("C:\Windows\System32\dhcpmgmt.msc")
        System.Diagnostics.Process.Start("C:\Windows\System32\dsa.msc")

    End Sub


Blessings

Jez
0
I am trying to load an image, place a text, draw lines, then save.
The following is my code, it loads ok, draws ok, but saving saves only the loaded image without the placed text or lines.

Is there a way to solve it?

        Dim FontNameIs, TextLineIs As String
        Dim FontSizeIs, CurrX, CurrY As Integer
        Dim fontToMeasure As New Font("Microsoft Sans Serif", 14, FontStyle.Bold)

        PictureBox1.Load("MyPictureFile.JPG")

        TextLineIs = "Text to be placed on top of MyPictureFile.jpg"
        FontNameIs = "Arial"
        FontSizeIs = 14
        CurrX = 20
        CurrY = 50

        PictureBox1.CreateGraphics.DrawString(TextLineIs, New Font(FontNameIs, FontSizeIs), Brushes.Black, CurrX, CurrY) 'placing a text

        Dim P As Pen = New Pen(Color.Black)
        PictureBox1.CreateGraphics.DrawLine(P, 20, 50, 492, 50) 'drawing a line

        If PictureBox1.Image IsNot Nothing Then
            PictureBox1.Image.Save("C:\test.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
        End If
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,