Go Premium for a chance to win a PS4. Enter to Win

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

I've got a VB 2015 / ASP app that features a Gridview  displaying 6 columns of data via a SQL query.
I wish to add a new column at runtime, and poke in a text string based off cell text in column1(0 based)
Here's what my aspx Gridview section looks like:
         
   <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False" DataSourceID="SqlDataSource1" Height="486px" Width="661px">
                <columns>
                    <asp:BoundField DataField="spid" HeaderText="spid" SortExpression="spid" />
                    <asp:BoundField DataField="Login" HeaderText="Login" ReadOnly="True" SortExpression="Login" />
                    <asp:BoundField DataField="DB" HeaderText="DB" ReadOnly="True" SortExpression="DB" />
                    <asp:BoundField DataField="SERVER" HeaderText="SERVER" SortExpression="SERVER"/>
                    <asp:BoundField DataField="LOGIN TIME" HeaderText="LOGIN TIME" ReadOnly="True" SortExpression="LOGIN TIME"/>
                    <asp:BoundField DataField="USER COUNT" HeaderText="USER COUNT" ReadOnly="True" SortExpression="USER COUNT"/>
                    <asp:TemplateField HeaderText="SITE"   runat="server"></asp:TemplateField>
                </columns>
            </asp:GridView>

Open in new window


In my code behind, I have a For loop where I'm doing some gridview manipulation such as cell coloring..etc
and I thought maybe I could do something similar to:
For i = 0 To GridView1.Rows.Count - 1
nameToCheck = GridView1.Rows(i).Cells(1).Text
nameToCheck = nameToCheck.Trim()

If nameToCheck = "MYNAME" Then GridView1.Rows(i).Cells(5).Text = "ME"

Open in new window


Here's a snippet of what the grid looks like at runtime:
Capture.PNG
I want to query cell#2 for a value, and depending on the result, poke some text into my new column/cell...
make sense?
Am I even remotely close??
Rich
0
Concerto Cloud for Software Providers & ISVs
LVL 5
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

i have access table with image fields
i want retrieve all images in the table into listview1  using vbnet
0
Hi EE,

I have following code in VB.NET.

Public Function GenerateUniNo(ByVal Length As Integer) As String
        Randomize()

        Dim ValidChars As String
        ValidChars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"

        Dim i, x As Integer
        Dim password As String = ""
        For i = 1 To Length
            x = Int(Len(ValidChars) * Rnd() + 1)
            password = password & Mid(ValidChars, x, 1)
        Next
        GenerateUniNo = password
    End Function

Open in new window


and it is called using following statement :

Dim dr = dbCommE.ExecuteReader()
            If dr.HasRows Then
                txtUniNo.Text = GenerateUniNo (4)
                If dr(0) = Trim(txtUniNo.Text) Then
                    txtUniNo.Text = ""
                    txtUniNo.Text = GenerateUniNo (4)
                End If
            End If

Open in new window


How to write trigger or procedure in MYSQL so that same task can be achieved?

Please guide.

Regards,
D Patel
0
I Have just finished developing a VB.net windows form app, and I want to lauch it from my Acces-based user menu app (which checks if the user is authorized to run the app), but it comes always withe warning message box about virues and being "certain that this file is from a trustworthy source".

I've added the directory where the exe file is in the Trust Center settings to the  trusted locations list, it doesn't change anything, the warning still comes up, and when I click OK in the warning box, the vb app is started, but the warning message box remains open, and when I forcibly close it, an error message comes up, saying the hyperlink I'm using in Access to start the app "cannot be followed".

All this is very annoying, it will look like a mess to any user ! The galling thig is that starting the vb exe directly does NOT generate any warning messages...

Is there an easy way to get rid of this without having to do anything complicated such as certifying the app ? Will I have to integrate the user authorization software directly in the vb app, cutting my Access menu out in the process ?

Thanks for help
Bernard
0
Hi All,

I try below, but error.

   SqlCommand.Parameters.AddWithValue("@CrtDate", Me.dtpTglTerima.Value.ToString("yyyy/MM/dd") + " " + ERV_Global.Get_Server_Date.TimeOfDay.ToString("hh:mm:SS"))

What's wrong ?

Thank you.
0
I am trying to rewrite this in a VB.NET form which is manipulating a Word document, but running into a number of problems.

Original VBA in Word
Dim rng As Range
Dim intPages As Integer

With ActiveDocument
    For intPages = Selection.Information(wdNumberOfPagesInDocument) To 0 Step -1
        Set rng = .GoTo(What:=wdGoToPage, Name:=intPages)
        Set rng = rng.GoTo(What:=wdGoToBookmark, Name:="\page")
        If Len(rng) = 2 Then
            rng.Delete
        End If
    Next
End With

Open in new window


My attempt to rewrite in VB.NET
    Private Sub Button2_Click_1(sender As Object, e As EventArgs) Handles Button2.Click

        Dim oWord As Microsoft.Office.Interop.Word.Application
        Dim oDoc As Microsoft.Office.Interop.Word.Document
        Dim oTable As Microsoft.Office.Interop.Word.Table
        Dim oPara1 As Microsoft.Office.Interop.Word.Paragraph, oPara2 As Microsoft.Office.Interop.Word.Paragraph
        Dim oPara3 As Microsoft.Office.Interop.Word.Paragraph, oPara4 As Microsoft.Office.Interop.Word.Paragraph
        Dim oRng As Microsoft.Office.Interop.Word.Range
        Dim oShape As Microsoft.Office.Interop.Word.InlineShape
        Dim oChart As Object
        Dim Pos As Double

        Dim oPages As Microsoft.Office.Interop.Word.Pages
        Dim intPages As Integer

        'Start Word and open the document template.
        oWord = CreateObject("Word.Application")
        oWord.Visible = True
        oDoc = 

Open in new window

0
Trying to find an example of an httpWebRequest vb.net or c# on the QualPay Payment Gateway site.

An authorization would be fine.  Just need to get an example of SOMETHING posting
0
Hi

How do I open a new workbook in the same window. When I open a workbook it does it in a new window.
This is for my Excel VB.net Add-in which uses task panes.

Thanks
0
Picture0004.pngPicture0004.pngPicture0004.pngPicture0004.pngPicture0004.pngPicture0004.pngHello Experts -

I've spent about 5 hours trying to register a COM DLL in VB.NET.

This is admittedly a new machine for me. Regsvr32 says it can't find the binary.

See the attached snapshot.

I wonder if there might be some special level of security that is preventing me from doing the registration function. I've been thru the Command Prompt with Administrator rights.

Gordon
Picture0004.png
0
Can I identify whether or not an "exe" is currently running in lotusscript?
0
What does it mean to be "Always On"?
LVL 5
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Hi EE,

I need help in generating the Unique Number of 4 character length.

Criteria is as follows :
  1. String will always start with alphabet
  2. Another 3 characters will be a combination of alphabets (A-Z) and digits (0-9)
  3. Once the number generated it could not be repeat

Example
A001, A999, ZD01, DA9P, SXS8 etc...

I need to write a logic for the same in my ASP.NET (VB.NET) based web application.

Please provide a direction.

Regards,
D Patel
0
Hi,
I need to the following code to custom function.Any idea appreciate
 if (TxtPostcode.Text == null && string.IsNullOrWhiteSpace(TxtPostcode.Text))
                    {
                        validate = 1;
                    }

                    if (TxtDestinationName.Text == null && string.IsNullOrWhiteSpace(TxtDestinationName.Text))
                    {
                        validate = 1;
                    }

                    if (TxtDestinationDescription.Text == null && string.IsNullOrWhiteSpace(TxtDestinationDescription.Text))
                    {
                        validate = 1;
                    }

Open in new window

0
Trying to populate my combobox.  I get an error on "ValueMember".  When I bypass that statement the combobox is filled with "System.Data.DataRow".
    Private _results As New List(Of DataRow)

    Dim SQL As String = String.Empty
    Dim sqlData As New SQLData

    Private Sub PopulateSuppliers()

        Me.cbSupplier.Items.Clear()
        Me.cbSupplier.DataSource = Nothing

        SetSupplierSQL()
        _results = sqlData.SelectStatement(SQL)

        Me.cbSupplier.DataSource = _results
        Me.cbSupplier.DisplayMember = "id"
        Me.cbSupplier.ValueMember = "name"

    End Sub

Open in new window


Any ideas?
0
I user HelpRequested event to handle help. It works fine with F1 key, but it also works with Shift F1, I want to stop Shift F1.
0
I'd like to read the report or text file generated below (3rd from last line) into a textbox:
        Dim config As New MarketplaceWebServiceConfig
        config.ServiceURL = "https://mws.amazonservices.co.uk"
        Dim myClient As New MarketplaceWebServiceClient(AccessKey, SecretKey, ApplicationName, ApplicationVersion, config)
        Dim myRequest As New GetReportRequest
        myRequest.Merchant = SellerID
        myRequest.ReportId = reportId
        myRequest.Report = File.Open("C:\\report\" + reportId.ToString + ".txt", FileMode.OpenOrCreate, FileAccess.ReadWrite)
        Dim myResponse As New GetReportResponse
        myResponse = myClient.GetReport(myRequest)

Open in new window


If I add a final line:
myTextbox.text = File.ReadAllText("C:\\report\" + reportId.ToString + ".txt")

Open in new window

I get "The process cannot access the file "xxx" because it is being used by another process."

What do I need to do to ensure the file is written to and closed before attempting to read from it?
0
An app was written by another developer.  App contains multiple projects.  One was written in VB and another in C#.  Why?  I don't know.

I created a helper class called "FolderLocation" which is in the VB project.

VbProj -> HelperClass (Folder) - FolderLocation (Class)

I want to reference the Folder in the C# project

C#Proj -> DeliveryEmailer (Folder) -> Sender (Class).

There is a project dependency to the C# Proj in the VB Proj.  I can't add a project dependency to the C# referencing the VB Proj because it will create a circular reference.

Any ideas?
0
Hello I have a series of text boxes to record telephone numbers.  Like this:
Phone Number: (<asp:TextBox ID="txtContHomePh1" runat="server" MaxLength="3" Width="32px"></asp:TextBox>
                       )
                       <asp:TextBox ID="txtContHomePh2" runat="server" MaxLength="3" Width="31px"></asp:TextBox>
                       &nbsp;-
                       <asp:TextBox ID="txtContHomePh3" runat="server" MaxLength="4" Width="49px"></asp:TextBox>

Open in new window

txtContHomePh1 is the area code, txtContHomePh2 is for the next 3 number, and txtContHomePh3 is for the last 4 digits. I want a RequiredFieldValidator to make sure the user fills out the boxes.  Can I use just 1 for all 3 textboxes? Or do I have to put one on each text box?
0
0
down vote
favorite
I have a serial device which sends me data at the baudrate of 38400 and i get it like this ?@D00014C000 000. I can see data comes in on a ritchtextbox but what im trying to do is to use some characters from the string in a list box. For example i want characters "14C" appears in the listbox3. I tried the substring and mid function but listbox lidnt work properly and losses characters or confuse them . Here is my code. Any suggestions please?? i am using visual studio express 2012

Imports System
Imports System.ComponentModel
Imports System.Threading
Imports System.IO.Ports
 
Public Class frmMain
    Dim myPort As Array
    Delegate Sub SetTextCallback(ByVal [text] As String)
  
 
    'Serial Port Receiving Code Starts Here ....
    Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
        ReceivedText(SerialPort1.ReadExisting())
 
    End Sub
    'Serial Port Receiving Code Ends Here ....
 
    'Serial Port Receiving Code(Invoke) Starts Here ....
    Private Sub ReceivedText(ByVal [text] As String)
        If Me.rtbReceived.InvokeRequired Then
            Dim x As New SetTextCallback(AddressOf ReceivedText)
            Me.Invoke(x, New Object() {(text)})
 
           
 
        Else
            Me.rtbReceived.Text &= [text]
              Dim fine As String = Mid([text], 7, 3)
            Dim list As Integer = ListBox3.Items.Add(fine)
        End 

Open in new window

0
Hi, do you have any shortcut for avoiding special characters in textbox?
im using this manual code:

Public Class Form1
    Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        If TextBox1.ToString.Contains("`") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("~") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("!") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("@") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("#") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("$") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("%") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("^") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("*") Then
            MsgBox("Text contains invalid character(s)", vbInformation, "Invalid!")
        ElseIf TextBox1.ToString.Contains("&") Then

Open in new window

0
[Webinar] Cloud and Mobile-First Strategy
LVL 11
[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

I'm using VB.Net to run a program that connects to a SQL Server Express database.
My connection string is this:
Public Const LocalDB As String = "User ID=sa;Password=*******;Initial Catalog=tempOrders;Data Source=v7p\SQLEXPRESS"

Open in new window


Here is the error message I'm getting.  orderr_trans_error.jpg
This program has been running all day and only stopped about an hour ago.  
Nothing was changed on our system as far as we can tell - and no code was changed in the VB.Net program.

Any suggestions on things we can try?  This problem happend a couple of days ago - and after a few hours it started working.  Very odd.

I can access the database using the credentials I have using Management Studio.

Any help or suggestions you have will be appreciated!

Thank you!

Steve
0
I have a vb.net Windows Forms application compiled in Visual Studio 2013 using .NET 4.0 (not client profile), x86 target cpu.  The application has been running on multiple machines across dozens of networks for several years.  Suddenly a couple of weeks ago it stopped running on 64 bit machines on 1 network. 32 bit machines still run it from the same server. 64 bit machines are running .NET 4.6. Windows updates were rolled back, firewalls turned off, running as administrator, anti virus turned off, user network permissions are good. Any tips would be greatly appreciated.
0
I've got a working ASP app with a gridview populated via a SQL select string.
I'd like to add a column at the end of the gridview, and populate it in a For loop, where I'm doing some other checks when the gridview refreshes..

Something like:
                    GridView1.Rows(i).Cells("MYNEWCOLUMNNAME").Text = "hi"

Open in new window

I tried adding a new column in the gui "SITE", as a BoundField, but I'm thinking this isn't going to work quite that easily..

Thoughts?
0
Hi

I get the following error when trying to populate a DatagridView using VB.net code.
What is the best way to handle this error?

Thanks

1
0
Hello, I would like to create a VBA in Outlook 2013 to move an email after reading the body of the email message with the following text:
_stopRequested= False
Files that don't exist: 0

Open in new window

Any thoughts ? Or better way to do this ?

Thanks for your help
0
Hi

I have developed a number of console apps, but this is my first Windows forms-based app, with a DataGridView control (which is showing the data in a datatable) where users can add rows. When they insert a new row, I want to set some columns of that row automatically (insertion date/time, user name, that kind of stuff).

I don't knw how to do that... Can you help ?

Thanks
Bernard
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,