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

(Object reference not set to an instance of an object)

The following code (sometimes) give the above error only if the file is a (multi page tiff file with a large number of pages)  e.g.  400 pages or 500 pages. Not on a specific page.
and when I check     PictureBox1.Image     I find it = null!
If I reRun my software it works fine on the same page that it stopped on.
I feel it is something related to memory   (e.g.   executing the next line before full load .....)
Any help is appreciated.

PictureBox1.Image = Image.FromFile("C:\ImgFolder\ImageName.tif")
Dim NoOfPages As Long = PictureBox1.Image.GetFrameCount(Imaging.FrameDimension.Page)

For J = ImagePageFrom - 1 To ImagePageTO - 1
       PictureBox1.Image.SelectActiveFrame(Imaging.FrameDimension.Page, J)    'the error is on this line
       PictureBox1.Image.Save("C:\ImgFolder\ImageName.Gif", Imaging.ImageFormat.Gif)
Next
PictureBox1.Image = Nothing
0
i have used the linq code like the example below to construct a list of customers with the respective value,

Dim bunds As IEnumerable = (From dr In duse _
                     Group dr By a = dr.Field(Of Decimal)("msisdn") Into grp = Group Select New With
                            { _
                                .msisdn = a, _
                                .data_bytes_bundle = grp.Sum(Function(x) If(x.Field(Of Decimal)("bonus") = 1, x.Field(Of Decimal)("byts"), 0)),
                                .data_bytes_bonus = grp.Sum(Function(x) If(x.Field(Of Decimal)("bonus") = 2, x.Field(Of Decimal)("byts"), 0))
                            }).ToList

I have three list which i want to put into a single collectio using linq, it is failing at  o.msisdn with massage
Object variable or With block variable not set.

 Dim result = (From c In bunds
             Group Join o In core
             On c.msisdn Equals o.msisdn Into co = Group
             From o In co.DefaultIfEmpty() Join p In pcrf On o.msisdn Equals p.msisdn
             Select o.msisdn, o.data_bytes_bundle, o.data_bytes_bonus, o.data_bytes_core, p.byt_pcrf, p.byt_pcrf_bon).ToList

I am failing to get out of this
0
Dear Experts

I have the code below
But in the last query that starts with "  Dim bund As IEnumerable" it is complaining "wallet_type_cd is not in datatable bund",  it is true it is in datatable wallets

How do i point to datatable wallets;

Thank you

  odadp = New OracleDataAdapter("select msisdn_nsk as msisdn, regexp_substr(flex_3_txt,'[^~]+',1,1) as byts, ded_acc_id from " & _
                                      " stg_cdr.cs5_ccn_wmx_da where date_key = 20180801 " & _
                                      " AND (REGEXP_SUBSTR(FLEX_3_TXT,'[^~]+',1,1)) <> 'X' " & _
                                      " AND (REGEXP_SUBSTR(FLEX_2_TXT,'[^~]+',1,7)) <> 'X' " & _
                                      " AND (REGEXP_SUBSTR(FLEX_2_TXT,'[^~]+',1,7)) IS NOT NULL  " & _
                                      " AND (REGEXP_SUBSTR(FLEX_2_TXT,'[^~]+',1,13)) = '3333' and rownum <= 10000", conn)
        odadp.Fill(udat, "bund")

        odadp = New OracleDataAdapter("select wallet_type_cd, wallet_cd,wallet_key from bib.dim_wallet", conn)
        odadp.Fill(udat, "wallets")

        Dim wallets As IEnumerable = (From dr In udat.Tables("wallets").AsEnumerable() Select dr).ToList

        Dim bund As IEnumerable = (From dr In udat.Tables("bund").AsEnumerable() Join wallet In udat.Tables("wallets").AsEnumerable() _
                                  On dr.Field(Of String)("ded_acc_id") Equals wallet.Field(Of String)("wallet_cd")
                     Group dr By a = …
0
Below vbscript code (.VBS)  changes Date format of one of the date column (Date)  from to "mm/dd/yyyy"  to "dd/mm/yyyy" . when saved to Excel.


Row Number|Row Action|Department|Date
123456          |Insert          |Airlines         |05/12/2016
3456              |Update       |Engineering |10/31/2014
234234         |Insert          |Arts                |2015
452435         |Insert          |Design           |2016


' Define constants
Const cExcel7 = 51
Const xlContinuous = 1
Const xlEdgeBottom = 9
Const xlEdgeLeft = 7
Const xlEdgeRight = 10
Const xlEdgeTop = 8

' Create file system object
Set objFSO = CreateObject("Scripting.FilesystemObject")

' Files to work woth
strInputFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\Input.txt")
strInputExcelFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\Input.xlsx")
strOutputFile = objFSO.GetAbsolutePathname("C:\Users\sktneer\Desktop\output-23-10.xlsx")

' Read text file into array
With objFSO.OpenTextFile(strInputFile, 1)
    arrInput = Split(.ReadAll, vbNewLine)
End With

' Start Excel, create a new worksheet
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = False
objexcel.Application.SheetsInNewWorkbook = 3
Set dwb = objExcel.Workbooks.Add
Set objSheet = dwb.Worksheets(1)

' Initialize row index
intRow = 0

' Process each line of input file
For Each strInput in arrInput

    ' Skip all blank lines
    If strInput <> "" Then
        …
0
Hi All,

I have a key from BigInt Identity to UniqueIdentifier.

The problem is not all database change, some server are not changed yet.

  sbdSQLCommand.AppendLine("SELECT")
                sbdSQLCommand.AppendLine("ID")
                sbdSQLCommand.AppendLine("FROM TDPOJUAL")
                sbdSQLCommand.AppendLine("WHERE Nomor_OA = @Nomor_OA ")
                sbdSQLCommand.AppendLine("AND BarangCode = @BarangCode ")

                cmdSQLCommand.CommandType = CommandType.Text
                cmdSQLCommand.CommandText = sbdSQLCommand.ToString

                cmdSQLCommand.Parameters.Clear()

                cmdSQLCommand.Parameters.AddWithValue("@Nomor_OA", txtNomor_OA.Text)
                cmdSQLCommand.Parameters.AddWithValue("@BarangCode", dtRow("BarangCode"))

                HideKeyTDPOJUAL = cmdSQLCommand.ExecuteScalar()

                dtRow("IDDetailSO") = HideKeyTDPOJUAL

The  variable HideKeyTDPOJUAL is GUID at the moment.

How could I code it to make it work for both BigInt and UniqueIdentifier ?

Thank you.
0
A SQL SP returns the message ex.Message = "Conversion from type 'DBNull' to type 'String' is not valid." Turns out that putting a watch on cmd.Parameters the watch states error BC30456: 'Paramete' is not a member of 'SqlCommand'.      Cannot reason why this is so. The parameter is created and added to command.parameters. If a string literal is used it works. Thank you for any help.

 Dim cmd As New SqlCommand("[HTS].[TaskCompleted_SELECT_CompletedTasks_02_USES HortDoc_ID]") With {
                .CommandTimeout = 60,
                .CommandType = Data.CommandType.StoredProcedure
            }

             Dim HortDoc_ID = New SqlParameter With {
                .Direction = ParameterDirection.Input,
                .DbType = DbType.String,
                .Size = 12,
                .ParameterName = "@HortDoc_ID",
                .Value = g_HortDoc_ID.ToString,  'doesn't work
                .Value = "28" 'works
            }            

cmd.Parameters.Add(HortDoc_ID)

            Dim conn As New SqlConnection(mConnectionStrings.ConnHortDB)
            conn.Open()
            cmd.Connection = conn

            Dim str As String
            str = cmd.ExecuteScalar
            Return str
            conn.Close()

Open in new window


ALTER PROCEDURE [HTS].[TaskCompleted_SELECT_CompletedTasks_02_USES HortDoc_ID]
(
	@HortDoc_ID	as varchar(12)
)
AS

declare @objcursor as cursor 
 
declare 
    @vsql       as nvarchar(max)
    ,@vquery    as nvarchar(max)
    ,@id        as int
    ,@value     as varchar(50)
    
DECLARE @list varchar(1000)
DECLARE @listTemp varchar(100)
DECLARE @item varchar(300)

set @vquery = 'SELECT DISTINCT Task_CD from HTS.TaskCompleted WHERE HortDoc_ID = ' +  @HortDoc_ID
.
.
.

Open in new window

0
Good morning, I have a quick question about lists. I have multiple List(of FileInfo) that searches for employee paperwork. Why? I need to know what files are turned in and then iterate through the schedule database to find missing paperwork (check days worked vs paperwork turned in (Dates) to find information). Problem: If I create a list for each employee that holds the missing paperwork dates, can I place each list into 1 container and then iterate through the big container to retrieve those dates to generate a report or am I making this too complicated??? Each Date in each container goes to a specific listbox so I can see individually who is turning in late work. Any advice would be great, thank you!


                   
Dim Provider1 As New List(Of FileInfo)
                    Dim Provider2 As New List(Of FileInfo)
                    Dim Provider3 As New List(Of FileInfo)
                    Dim Provider4 As New List(Of FileInfo)
                    Dim Provider5 As New List(Of FileInfo)
                    Dim Provider6 As New List(Of FileInfo)
                    Dim Provider7 As New List(Of FileInfo)
                    Dim Provider8 As New List(Of FileInfo)
                    Dim Provider9 As New List(Of FileInfo)
                    Dim Provider10 As New List(Of FileInfo)
                    Dim NewFileInfo As New FileInfo(newname)
                    For Each Item In DirectoryList ' container holds directory information for each employee file 

Open in new window

0
I am looking to copy and paste data from one xlsx sheet to a new excel sheet using VBScripts . Could please some one help me using Vb script to paste exact contents from
excel-input.xlsx to a new excel excel-output,xlsx on sheet2   and rename sheet2 to DataSet.

Here is the

Excel-Input.xlsx
Name      age      gender      department      year
don                23      male      computer      2010
ptalakes       24      female      maths              2015
chang      28      male      arts                2016
prag      29      female      science              2018
tom               26      male      arts                      2017
john      27      female      sports              2018
simon      22      male      arts                      2018

Excel-Output.xlsx  (Rename sheet2 as data )
Name      age      gender      department      year
don                23      male      computer      2010
ptalakes       24      female      maths              2015
chang      28      male      arts                2016
prag      29      female      science              2018
tom               26      male      arts                      2017
john      27      female      sports              2018
simon      22      male      arts                      2018
Excel-input.xlsx
Excel-Output.xlsx
0
Am looking for help on how to write escape code to send commands to FP 700 fiscal printer. The SDK provided is in Java i need .net SDK

I have the commands used to tell a printer to do a certain function but i don't know how to embed these commands in my vb.net source code so that the printer can print
0
Need a week picker in a windows form to double click and open me a form to fill data then, when close put a mark in a week picker that this specific date is filled
any idea
vb.net
0
Hello
I have a VB.net program that retrieves data from an SQL Database.
I have to retrieve some large data sets and would like to run these in the background.

I am using MVM pattern and using the following code to retreive the data.
My question is how can I change this code to run Aysnc?

I have looked online but can't get anything to work.

Code in Data Access Layer that Retrieves Data from Database.

Thank you

Shared Function GetData(ByVal customerAccountNumber As Integer, ByVal includeInActiveProducts As Boolean, ByVal groupPeriodType As GroupPeriodEnum, ByVal salePeriodCount As Integer, ByVal groupFilterTypeID As GroupFilterTypeEnum,
                            ByVal groupFilterValue As Integer, ByVal staffID As Integer) As System.Data.Common.DbDataReader

        Try

            ' Create command to send to the database
            Using cmd As New SqlCommand("ppp_sp_Sales_ProductTotals", Sql.ConnSQL)
                cmd.CommandType = CommandType.StoredProcedure
                With cmd.Parameters
                    .AddWithValue("@StaffID", staffID)
                    .AddWithValue("@CustomerAccountNumber", customerAccountNumber)
                    .AddWithValue("@GroupPeriodType", groupPeriodType)
                    .AddWithValue("@IncludeInactiveProducts", includeInActiveProducts)
                    .AddWithValue("@SalePeriodCount", salePeriodCount)
                    .AddWithValue("@GroupFilterTypeID", groupFilterTypeID)
                   

Open in new window

0
I have a folder and in that I have multiple sub-folders , each containing a default.xml file. I need to rename all the default.xml within all these sub-folders with the same name as that of the sub-folder.

So that my default.xml will become sub-folder_name.xml.

Lets say My main folder is \sites\ASDF, within that I have 10 sub-folders -> ABC-123, DEF-231, ......like this and I want to rename the default.xml within all these sub-folder to ABC-123.xml, DEF-231.xml. It should be done by using Powershell. Any ideas?

rename-item –path "d:\a2\a11\SIT-E1236\default.xml" –newname d:\a2\a11\SIT-E1236\SIT-E1236.xml
rename-item –path "d:\a2\a11\SIT-E1238\default.xml" –newname d:\a2\a11\SIT-E1236\SIT-E1238.xml

This using some loop?

Also how can I edit some xml files together to make some particular changes on the xml nodes?
0
Is it possible to write an update query for use in a sqldatasource similar to this?  I cannot seem to figure out how to update the original QTY from the DB to (plus or minus), depending on the value entered in the grid edit column.

db
grid edit
Private Sub rgTG_EditCommand(sender As Object, e As GridCommandEventArgs) Handles rgTG.EditCommand
	If e.CommandName = "Edit" Then
		Dim item As GridEditableItem = TryCast(e.Item, GridEditableItem)
		Dim skey As String = item.GetDataKeyValue("TGID").ToString()
		Session("sTGID") = skey

		sqldsRGTG.UpdateCommand = "UPDATE [TubeGroups] SET QTY=(SELECT QTY FROM [TubeGroups] WHERE TGID=@TGID + @QTY) WHERE TGID=@TGID"
		sqldsRGTG.UpdateParameters.Clear()
		sqldsRGTG.UpdateParameters.Add("TGID", CType(Session("sTGID"), String))
		sqldsRGTG.UpdateParameters.Add("QTY", ?????)
		sqldsRGTG.DataBind()
	End If
End Sub

Open in new window


TIA,
Andrew
0
ciao a tutti, volevo sapere in che modo era possibile esportare dei dati da una tabella di un db su sql server in excel tramite framework .net su vb.net
Fino ad oggi uso questa procedura ma per tabelle con molti dati il procedimento impiega troppo tempo. Importo la tabella su un datatable o un datagridview per visualizzarla al front end, una volta caricata con una funzione che si basa sulla classe interop excel vado a ciclare tutte le righe della tabella e le scrivevo su un file excel.
Mi sono accorto che per tabelle molto grandi l'export dura troppo tempo, allora spesso ricorro all'importazione direttamente da excel sulla scheda dati/nuova query/da database/da database sql server. la scheda mi richiede il server, il database e la query e con pochissimo tempo con il net framework si caricano tabelle con molti dati, già convertite anche per ogni formato cella. La mia domanda è se la stessa procedura può essere richiamata da vb.net, quindi con una funzione che una volta passati i parametri di server,db,query scriva velocemente su un file excel (.xlsx)
0
SQl LocalDB MSSQLLOCALDB stopped working.   I have a vb.net program that has been running for months on a windows 10 4gb ram i5 laptop.  For some strange reason, it can no longer connect to the local database on that machine.

What i have tried.  
Using the sql utility i went to a command promt checked if MSSQLLOCALDB was there(it was) i stopped the instance, restarted the instance, still doesn't work
I then deleted the instance recreated it it again showed up (sqllocaldb i) when i try to start it i get an error message that says That sql cannot connect start fails.

I then deleted SQl Localdb from the control panel and reloaded it.  Again shows up won't start.  
i have searched and tried as many ideas found on the internet as i could.  I also cannot find the localDB in SSMS.  If i type it in the connect box it doesn't find it.
Any ideas?
0
Hi All,
We are trying to call ACMS Task (Vax/VMS) from VB.net code. We were able to do this in VB 6.0 but when we coneverted to dotnet (Vb.net 2015) we donot know how to call the ACMS Task written in VAX/VMS.
Please help. Thank you.
0
I have a GridVIew table in an ASP.net project. I need the column headings to be oriented vertically.

I have achieved this with the following steps:

1) Adding the following into the head:

    <style>
        .verticaltext
        {
            writing-mode: vertical-rl;
        }
    </style>

2) Adding the following into gvResults_DataBound:

For C = 2 To 16
      gvResults.HeaderRow.Cells(C).Text = "<div class=""verticaltext"">" & gvResults.Columns(C).HeaderText & "</div>"
Next

This has the required visual effect, but unfortunately breaks the ability to click the column heading to sort the table.

Can anyone suggest a way to re-orient the header text without breaking the sort functionality.

Thanks,

Richard
0
Hi,
How to create multiple PDF pages saved as one PDF file by PDFsharp or MergeDOC.

I have an working code creating only 1 page but not multi page.
Any suggestions are appreciated.

 Dim dtSQLImage As New DataTable
        Dim imagedt
        Dim imageData() As Byte

        Dim unicode = PdfFontEncoding.Unicode
        Dim embedding = PdfFontEncoding.Automatic

        Dim clsFrmain As New ClsFrmMainLoad

        dtSQLImage = DgFinanceImg.DataSource
        Dim pdfRenderer As PdfDocumentRenderer = New PdfDocumentRenderer(unicode, embedding)
        For j = 0 To dtSQLImage.Rows.Count - 1
            If j = DirectCast(sender, Telerik.WinControls.UI.RadGridView).CurrentRow.Index Then
                imageData = (dtSQLImage.Rows(j)(0))

                For i = 0 To 2

                    imageFilename = MigraDocFilenameFromByteArray(imageData)
                    document = New MigraDoc.DocumentObjectModel.Document
                    Dim pageSetup As MigraDoc.DocumentObjectModel.PageSetup = document.DefaultPageSetup.Clone
                    ' set orientation
                    pageSetup.Orientation = MigraDoc.DocumentObjectModel.Orientation.Landscape
                    Dim section As MigraDoc.DocumentObjectModel.Section = document.AddSection

                    Dim image = section.AddImage(imageFilename)

                    '  Image.Top = ShapePosition.Top
                    ' Image.Left = ShapePosition.Left
                    ' Image.WrapFormat.Style = 

Open in new window

0
Hi experts,

I'm using ASP.NET Web Forms with VB.

I have a DataGrid bound to a Sql Stored Procedure. The stored procedure fetches the Northwind Employees sql server table.

These are the SQL Scripts.

Script for the Table

USE [Northwind]
GO

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[NWEmployees](
	[EmployeeID] [int] NOT NULL,
	[LastName] [nvarchar](20) NOT NULL,
	[FirstName] [nvarchar](10) NOT NULL,
	[Title] [nvarchar](30) NULL,
	[TitleOfCourtesy] [nvarchar](25) NULL,
	[BirthDate] [datetime] NULL,
	[HireDate] [datetime] NULL,
	[Address] [nvarchar](60) NULL,
	[City] [nvarchar](15) NULL,
	[Region] [nvarchar](15) NULL,
	[PostalCode] [int] NULL,
	[Country] [nvarchar](15) NULL,
 CONSTRAINT [PK_Employees_NWEmployees] PRIMARY KEY CLUSTERED 
(
	[EmployeeID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO
INSERT [dbo].[NWEmployees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City], [Region], [PostalCode], [Country]) VALUES (1, N'Woods', N'Tiger', N'Actor', N'Ms.', CAST(N'1948-12-08 00:00:00.000' AS DateTime), CAST(N'1992-05-01 00:00:00.000' AS DateTime), N'507 - 20th Ave. E.
Apt. 2A', N'Seattle', N'WA', 93722, N'USA')
INSERT [dbo].[NWEmployees] ([EmployeeID], [LastName], [FirstName], [Title], [TitleOfCourtesy], [BirthDate], [HireDate], [Address], [City], [Region], 

Open in new window

0
Hi

I have an ASP.net TextBox. After the user has typed something and presses enter I want to call a VB.net
procedure called oInsertValues. How do I do this?

Thanks
0
I am trying to hide the chart axes and labels along with the series line color. I just want to show datapoint labels. I have successfully hidden all (by setting color to form's back color). However except for the dashes that appear at axes scale break points. (Please see the below image)



Could someone please help me with hiding these scale break dashes as well? Thanks in advance
0
Is it possible to place custom labels on a StripLine? I have a Horizontal stripline and want to place custom labels on some datapoints on this line. Could someone please give me code to do this? Thank in advance
0
How to restrict vertical stripline from x-axis to above x-axis but restrict it from extending below x-axis.

As you can see in the image below the current green vertical line is extending onto the side of negative Y-axis (i.e; below x-axis).



How can I not show the part of green vertical line below x-axis (indicated by red arrow)
Please let me know how to accomplish this. Thanks in advance.
0
I have a chart currently generated as shown in the image current_chart_mock.png




Is it possible to add labels below  few x-axis values. Please see the below attached image (MAP_mock.png) for what I am trying t ask for.



If possible, could someone please tell me how to accomplish this? Thanks in advance
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,