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

I am getting the error below in trying to get a GridView cell and row index using the following. I got this from the post https://forums.asp.net/t/1639326.aspx?Gridview+Cell+Click+Event+Get+Row+Column+Index
1. Javascript
// Javascript - get cell and row index
function cellClicked(row, column)
{
         document.getElementById('<% = hfAction.ClientID %>').value = "CellClick";
         document.getElementById('<% = hfRow.ClientID %>').value = row;
         document.getElementById('<% = hfColumn.ClientID %>').value = column;
         form1.submit();
}

Open in new window


2. VB.net
    Private Sub GridView1_RowDataBound(sender As Object, e As GridViewRowEventArgs) Handles GridView1.RowDataBound


        If e.Row.RowType = DataControlRowType.DataRow Then
            '//Following code used to change row color on mouseover
            'e.Row.Attributes.Add("onmouseover", "this.originalcolor=this.style.backgroundColor;" & " this.style.backgroundColor='#ccdfdf';")
            'e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;")
            For columnIndex As Integer = 1 To e.Row.Cells.Count - 1
                '//https://forums.asp.net/t/1639326.aspx?Gridview+Cell+Click+Event+Get+Row+Column+Index
                e.Row.Cells(columnIndex).Attributes.Add("onclick", String.Format("cellClicked({0},{1});", e.Row.RowIndex, columnIndex))
                e.Row.Cells(columnIndex).Attributes.Add("onclick", "alert(""CellClicked"");")
            Next

        End If

    End Sub

Open in new window



Open in new window

0
Hi. I am fairly new to JavaScript. How do I step through JavaScript and put line breaks in.
My code resides in an ASP.net VB.net web app

<script type="text/javascript">
        //variable that will store the id of the last clicked row
        var previousRow;
        
        function ChangeRowColor(row)
        {
            //If last clicked row and the current clicked row are same
            if (previousRow == row)
                return;//do nothing
            //If there is row clicked earlier
            else if (previousRow != null)
                //change the color of the previous row back to white
                document.getElementById(previousRow).style.backgroundColor = "#ffffff";
            
            //change the color of the current row to light yellow
 
            document.getElementById(row).style.backgroundColor = "#ffffda";            
            //assign the current row id to the previous row id 
            //for next row to be clicked
            previousRow = row;
        }
     </script>

Open in new window

0
Hi,

I am programming in Visual Studio 2015 a Visual Basic project.

Goal is to write errors to event log. I have tried several examples like mentioned in:
https://support.microsoft.com/nl-nl/help/301279/how-to-write-to-an-event-log-by-using-visual-basic-net-or-visual-basic

It is not working like I expect it to work allready at the start.

Dim sSource As String
Dim sLog As String
Dim sEvent As String
Dim sMachine as String

sSource = "My Application"
sLog = "Application"
sEvent = "Error description"
sMachine = environment.machinename.tostring

If Not EventLog.SourceExists(sSource, sMachine) Then
            EventLog.CreateEventSource(sSource, sLog, sMachine)
End If

Open in new window


When firing this code I get the error:

Unkonown error: 5
The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. The inaccessable logs: Security.

This happens immidiately when code reaches:
If Not EventLog.SourceExists(sSource, sMachine) Then

Open in new window


Anybody any idea how to fix this? Lots of articles on the internet but all regarding older versions of Visual Studio.

The exact code now is:
[code]Sub log_event(ByRef sEvent As String)

        Dim aLog As EventLog
        Dim myLog As New EventLog
        

Open in new window

0
I have a slideshow app that when a button is pressed it will cycle through  5 images.
I would like to be able to remove the need for a button and the slideshow just to start when the app is loaded.

Please see my code bellow:
ImageSlideshow.xaml
<Page
    x:Class="TimerInWindowsStoreApps.ImageSlideShow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:TimerInWindowsStoreApps"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">
    <Grid x:Name="LayoutRoot" Background="Black">
        <Grid Margin="0,50">
            <Grid.RowDefinitions>
                <RowDefinition Height="410"></RowDefinition>
                <RowDefinition Height="*"></RowDefinition>
            </Grid.RowDefinitions>
            <StackPanel Grid.Row="0" Margin="0,0,0,10" Grid.RowSpan="2">
                <Border BorderBrush="Black" Grid.Row="0" BorderThickness="1" Width="1080">
                    <Image x:Name="ImageSource" AutomationProperties.Name="ImageSource" VerticalAlignment="Center" Stretch="Fill" Height="auto" Width="auto">
                    </Image>
                </Border>
            </StackPanel>
            <Grid x:Name="Input" Grid.Row="1" Margin="0,10,0,0" VerticalAlignment="Top" HorizontalAlignment="Center">
                <StackPanel 

Open in new window

0
I am developing an electronic medical record (EMR) system.

I am designing and implementing the backend APIs using WCF.

Now, I have two system actors: secretary and doctor.

I designed the services according to the actor he/she is concerned.

[ServiceContract]
public interface ISecretaryService
{
}

[ServiceContract]
public interface IDoctorService : ISecretaryService
{
//the doctor has the functions of secretary in case she was absent!
}

Open in new window


The problem is I have duplicate code which is the implementation of the ISecretary contract in doctor service.
0
ASP.NET + JavaScript + Client Side CustomValidators - I Have Question  

I have a ASP.Net standard Web Form working on validation - www.enflow.com/CC/P1/EE.aspx

Click The Other Button and a text box will appear... do not put any text into that textbox

Now Click Submit Button and you will CORRECTLY get a Validation Summary Msg saying missing text for the Describe Other textbox

But if you put text into that textbox and click submit button again then you will keep getting the same validation error...

I think i am missing something simple in JScript ClientSide Validation Call or ??


Here is JScript for Client JS Call...
      function valOther(sender, args) {
          if (document.getElementById("<%=Other.ClientID %>").checked == true) {
              if (document.getElementById("<%=MoreOther.ClientID %>").value === null) {
                  args.IsValid = true;
              } else {
                  args.IsValid = false;
              }
          }
      }

Open in new window

Here is All the Code In this Webform
<%@ Page Language="VB" AutoEventWireup="false" Debug="true" MaintainScrollPositionOnPostback="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Web.UI.Page" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Import Namespace="System.data.OleDb" %>
<%@ Import Namespace="System.Web.UI.WebControls" %>

<%@ Register Assembly="System.Web, Version=2.0.0.0, Culture=neutral, 

Open in new window

0
I am capturing a string of data that has some no printable characters from a COM bus. I capture them with a string variable and then display them inside my listbox window.

I put breakpoints on the string variable after a capture the complete data from the COM bus and I see the non-printables in the watch window. However I don't see the non printable inside the listbox control.

Any ideas would be appreciated

Thanks in advance.
0
Hi,

I'm using below code for running some procedures and also i would like to show them their status in my data grid view as below.

But i'd like to know that is there any way to simplify these code or you think it's the best approach i can?

Especially i mean this type of blocks(i take one of them as an example from bigger code block)

          If nodeForceOut.Checked = True Then
                Dim rowIndex As Integer = FindRowDgv(nodeForceOut.Text)
                Try
                    StyleStatus(rowIndex, "Performing", Color.Yellow)
                    ForceOut.MeasureForceMarker()
                    ForceOut.ListForceOutputs()
                    StyleStatus(rowIndex, "Finished", Color.Green)
                Catch ex As Exception
                    StyleStatus(rowIndex, "Error Occured", Color.Red)
                    Tools.OutputLog.Print(Tools.OutputLog.Type.ERR, ex.Message)
                End Try
            End If

Open in new window


Any help would be grateful. Thank you.

        Public Shared Sub Run(ByVal mdl As IScrModel)
            If mdl Is Nothing Then
                Throw New ArgumentNullException(NameOf(mdl))
            End If

            Dim tView As TreeView = GUI.treCheckListMain
            Dim dgView As DataGridView = GUI.dgvCheckInfo
            dgView.Rows.Clear()

            For Each nodeParent As TreeNode In tView.Nodes
                If nodeParent.Checked Then
                    dgView.Rows.Add(nodeParent.Text, "In queue")

Open in new window

0
Create Session id after my save button click.
I'm trying to simply create a session id after my save button event. After i save my data, i'd like to have my session be the primary key of Table2 which is titled POMONTHID, so it's not visible in any of the code behind or stored procedure.

My original SQL Stored Procedure to insert my data is
ALTER PROCEDURE [dbo].[ReturnIDwithOutput]
	@Suppint Varchar(50),
	@VendorCode Varchar(10),
	@classgroupAllocID Varchar(10),
	@Season Varchar(4),
	@quarter Varchar(50),
	@Month Varchar(50),
	@DateAllocated Date,
	@StyleCreated Varchar(5),
	@EDIT BIT,
	@Category VARCHAR(50),
	@POID INT OUTPUT
	
AS
BEGIN
	SET NOCOUNT ON;
	--DECLARE @POID INT;
	INSERT INTO [dbo].[Table1] (Suppint,VendorCode,classgroupAllocID,Season,[quarter],CreateDate)
	VALUES (@Suppint,@VendorCode,@classgroupAllocID,@Season,@quarter,GETDATE());
	SET @POID = SCOPE_IDENTITY();
	
	INSERT INTO [dbo].[Table2](POID,[Month],DateAllocated,StyleCreated,EDIT,Category,CreateDate) VALUES (@POID,@Month,@DateAllocated,@StyleCreated,@EDIT,@Category,GetDATE());

END

Open in new window


the code behind to call the stored procedure from ASP objects is here:
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click

        Dim strConnString As String = ConfigurationManager.ConnectionStrings("connstring").ConnectionString
            Dim con As New SqlConnection(strConnString)
            Dim cmd As New SqlCommand()

            cmd.CommandType =

Open in new window

0
Hi,

I have a Microsoft Access database for projects and i added a Lookup&Relationship oclumn to my access database and i typed the values i wanted like an example below.
000495.jpg000496.jpg
But when i binding this datasource in my tool and insert combobox and set DisplayMember this column. I couldnt be able to see items in my combobox items collection.

I thought i'm making mistakes in this topic, any experts can help me where i am wrong ?

thanks.
0
Hi,

I'm using COM-interface enginnering software in my tool and getting some output channels from the program, and i'm listing them in datagridview in my tool.(Like Force, Torque, Displacement, Stifness etc. information ). Datagridview's column header text information comes from tool.

I'm trying to add their units to Column's Tag property, because in next steps i'd like to compare Newton, velocity, torque values in some tolerances,


So how is it possible to tag columns according to their header text keywords.

For example if column name contains Force, Newton, Output Force this column's tag will be "N", or Torque, Moment this column's tag will be "Nm", or Velocity, Speed etc. this column's tag will be "m/s".

How is it possible to do that? Any help would be grateful.

Thank you.
0
Hi Experts,

I'm using Visual Studio 2013 (yes, am roaming with the dinosaurs!) for VB development.

I would like to know the line count for each function and sub, broken down by module.
It would also be nice to be able to sort the results by line count.

Is there a free or inexpensive tool that will do this?

Regards,
Leigh
0
Hello,
I created login form and I was able to create rights for admin and user but it only makes the button that I want to disappear, but when I exit from the form and get back to it I see the button on the form, meaning when i click the login button it hides the buttons on the other form. how can I make those buttons hidden all the time when i login with user.
The code is attached
Thank you
0
Hi

In my ASP.net web app I pull data through to a GridView. One of the columns is  Date column.I have now been asked
to show the data with the dates along the top horizontally as opposed to vertically in a column. How would I go about this?
The image shows the dates at the top.

1Image1.png
0
Hi

In my ASP.net VB.net web app I am trying to view an image in one of my folders using the following two lines but the image is not appearing

     Dim FilePath As String = Server.MapPath("~/Uploads/" & oSelectedFile)
     Image1.ImageUrl = FilePath

Open in new window

0
I'm working on a vb.net program, and on my main form, I want a sub to run when another form in the program closes. The main form is called CurrentAmountsForm and one of the other forms is called InitialEntryForm.  I tried this sub, but it's not working.
    Public Sub InitialEntryForm_Closing(sender As Object, e As EventArgs) Handles MyBase.FormClosing
        LoadAmounts()
    End Sub

Open in new window


How can I execute my "LoadAmounts sub when another form closes?
0
Hi

I am having a problem that Excel is still running as a process.

  Private Sub LOADEXCEL()




        If IO.File.Exists(Fullpath) Then
            Dim Proceed As Boolean = False
            Dim xlApp As Excel.Application = Nothing
            Dim xlWorkBooks As Excel.Workbooks = Nothing
            Dim xlWorkBook As Excel.Workbook = Nothing
            Dim xlWorkSheet As Excel.Worksheet = Nothing
            Dim xlWorkSheets As Excel.Sheets = Nothing
            Dim xlCells As Excel.Range = Nothing
            Dim supplierworksheetexists As Boolean = False




            xlApp = New Excel.Application
            xlApp.DisplayAlerts = False
            xlWorkBooks = xlApp.Workbooks
            xlWorkBook = xlWorkBooks.Open(Fullpath)


            xlWorkSheets = xlWorkBook.Sheets




            For Each xlWorkSheet In xlWorkBook.Sheets

                Dim sheetname As String = xlWorkSheet.Name


                loaddatatable(xlWorkSheet.Name)


                'Only interested in first sheet
                Exit For
            Next


            NAR(xlWorkSheets)

            NAR(xlWorkSheet)
            xlWorkBook.Close(False)
            NAR(xlWorkBook)
            NAR(xlWorkBooks)
            xlApp.Quit()
            NAR(xlApp)









        Else
            MessageBox.Show("'" & "" & "' not located. Try one of the write examples first.")
        End If


    End Sub

Open in new window





 Private Sub loaddatatable(ByVal WorksheetName As String)

      

Open in new window

0
Hi

In ASP.net what code would I use to check if a certain file is a pdf. I want to add this check to the following code

    Protected Sub btnView_Click(sender As Object, e As EventArgs) Handles btnView.Click
        Try
            Dim oSelectedFile As String
            If Me.ListBox1.SelectedItem.Text <> "" Then
                oSelectedFile = Me.ListBox1.SelectedItem.Text
            Else
                Exit Sub
            End If
            'Response.Clear()
            'Dim filePath As String = "~/Uploads/" & oSelectedFile
            'Response.ContentType = "application/pdf"
            'Response.WriteFile(filePath)
            'Response.TransmitFile(filePath)

            'Dim FilePath As String = Server.MapPath("piyushsir.pdf")
            Dim FilePath As String = Server.MapPath("~/Uploads/" & oSelectedFile)
            Dim User As New System.Net.WebClient()
            Dim FileBuffer As [Byte]() = User.DownloadData(FilePath)
            If FileBuffer IsNot Nothing Then
                Response.ContentType = "application/pdf"
                Response.AddHeader("content-length", FileBuffer.Length.ToString())
                Response.BinaryWrite(FileBuffer)
            End If

        Catch ex As Exception
            'Response.Write(ex.Message)
            Me.lblErrorDeleting.Text = ex.Message & " hr556"
        End Try
    End Sub

Open in new window

0
How can I authenticate the User ID and Password to be valid from VB.Net and VB6 programs with Windows 7 Active Directory?
0
Hello I'm troubling with my application's font size. I don't know how to handle for different screen resoulitons and most of them i set with the Visual Studio designer.

I'm trying to set font Segoe UI and with 10pt but in different controls the size seems different even the designer properties are same.

Now i'd like to clarify, what's the experts in ux approach

set the font in designer or runtime?
using point or pixels ?
How do you handle Microsoft Font Size(Display Settings) and screen resouliton.
Any help would be greateful.

Thanks.
0
Hi,

As you can see below picture my font sizes seems different on controls. But i set all of them Segoe UI 9.75 pt. Why this is happening and how can i solve that?

Any help would be grateful.
Thanks.
Hakan000494.jpg
0
Hello,

I have a third part COM interface to get some information. In here there's special classes for that objects which i bring from COM interface.

These classes have some properties and these properties are also in type of different classes. I'd like to list two object differences but don't know how to do that programmatically because this is only one class type there's also more than 30 classes with different type of property classes.

Is there anyway to do that? I'd like to recursively check properties and if its output class has properties i'd like to get them also.

Any help really really helpful, i'm needing guidance of experts.

Regards.

Picture1.png
0
Hello,

I'm searching for project management and gantt chart tools. Does anyone know any library for this purpose.

Thank you.
0
Hi,

I'm creating some datagridviews on my tool but i dont know how to crate them an event?

For example i'd like to create DataGridViewCell click event.

Any help would be grateful.

Regards,
Hakan
0
Hello,

I'm trying to find all datagridviews under listed in my TabControl "tcMain" but the datagridview levels are different some of them containing in tabpage some of them containing under panel.

How is it possible to get all of them.

Any help wouıld be grateful.

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