vb.net

.NET - Microsoft.Office.Interop.Excel and Interop.Excel DLL

Hi, When I add a reference to Microsoft.Office.Interop.Excel on my computer, Visual Studio adds this to the project file: <COMReference Include="Excel"> <Guid>{00020813-0000-0000-C000-000000000046}</Guid> <VersionMajor>1</VersionMajor> <VersionMinor>5</VersionMinor> <Lcid>0</Lcid> <WrapperTool>primary</WrapperTool> <Isolate...

What is the best way to calculate word frequency in VB.NET?

There are some good examples on how to calculate word frequencies in C#, but none of them are comprehensive and I really need one in VB.NET. My current approach is limited to one word per frequency count. What is the best way to change this so that I can get a completely accurate word frequency listing? wordFreq = New Hashtable() Dim ...

VB.Net error: Index was outside the bounds of the array

This error comes out whenever I clicked the datagrid. Program does fill the datagrid every time data was selected in the combobox. For example: I choose data1 which has 4 records in datagrid. then I click row index no 1. No problem will shown but when I choose again another data in combobox, for example: Data 2 has only 1 record then ...

Where is the documentation for My feature in VB.Net?

No I'm not being a wise guy ... For those fortunate enough to not know the My class: It's something that was added in VB 2005 (and doesn't exist in C#) and is best described as a 'speeddial for the .net framework'. Supposed to make life easier for newbies who won't read which framework classes they should be using Dim contents As Stri...

How do I sanitize CSV input with the CsvReader?

I'm using the CsvReader library in my Windows Forms application, which is coded in horribly messy VB (I've recently taken over the project.) I'm currently capable of reading semi-colon separated files without quoting, but I'm having a problem: most of the input has quoted fields, but includes unescaped quote characters within the field...

ADO.NET Data Services Query Interceptor - can anyone tell me the VB syntax of this C#?

Hi folks, I am pretty new to VB.NET - and I'm struggling to convert the signature of the method in the following code snippet. The Expression<...>> bit. Thanks in advance. [QueryInterceptor("Orders")] public Expression<Func<Orders,bool>> OnQueryOrders() { return o => o.Customer.ContactName == HttpContext.Current.User...

What is the best way to sort using a GridView and LINQ?

The one thing that LINQ seems to be missing for me is a way to reference columns by text string. For example, I have a typical GridView set up with sorting like this (the DataSource is bound to a LINQ query in the code-behind): <asp:GridView ID="MyGridView" runat="server" AllowSorting="True"> <Columns> <asp:BoundField DataFi...

Save Windows Form Size

I'm developing a piece in VB.NET. Inside my primary form, I'm creating a new form to use as a dialog. I was wondering if there was a way to, upon the close of the new dialog, save it's size settings for each user (probably in a file on their machine, through XML or something?) ...

Printing in VB.Net/C# Forms Application -- Layout Designer?

I maintain a vb.net forms application that prints various labels to label printers. (Label printers are just like any printer, just smaller print area/lower resolution) The system uses a legacy printing method that's supported in the printer hardware, but has been out of general use for over a decade. I'm adding logic to print from ...

Is the Microsoft.VisualBasic namespace "true .NET" code?

My dev team is getting ready to start a new project. The shop has been a "VB shop" since the days of VB3, but the prevailing opinion now is that we're a ".NET shop" and since C# was created specifically for .NET, whereas VB.NET was a retrofit, we've decided to move forward writing C# only. The controversy revolves around the question of ...

Turn off auto-collapsing for VB.NET in Visual Studio?

The auto-collapse feature for code properties is neat AFTER you've got your properties all worked out, but while you're still editing them I find the feature to be REALLY annoying. How can you disable it? (I'm in VS2008 if it makes a difference) Edit: I'm not talking about the Property Window... I'm talking about properties in code. ...

Convert Byte Array to Integer In VB.Net

I'm wonder what the best way to convert a byte array (length 4) to an integer is in vb.net? I'm aware of BitConverter, but it seems like quite a waste to do a function call to do something that should be able to be done by copying 4 bytes of memory. Along the same lines, what about converting a single/double from it's binary representat...

Send Email in .NET, with email saved in user's Sent Items

Hi, I am attempting to send an email using VB.NET. There are two requirements The email be saved in their "Sent Items" folder in Outlook (their only email client). A PDF (generated on the fly) is attached to the email. I am currently creating a new MailMessage & sending via a SmtpClient, but I believe that this sends from the serve...

Round to increments of 2.5?

I need to round a value up to the nearest multiple of 2.5. For example: 6 --> 7.5 7.6 --> 10 etc. This seems like the best way to do this? Function RoundToIncrement(ByVal originalNumber As Decimal, ByVal increment As Decimal) As Decimal Dim num = Math.Round(originalNumber / increment, MidpointRounding.AwayFromZero) * inc...

Suggestions to improve VB.NET URL shortener?

Here is my function (updated): Public Shared Function shortenUrl(ByVal URL As String) As String Return shortenUrl(URL, 32) End Function Public Shared Function shortenUrl(ByVal URL As String, ByVal maxLength As Integer) As String If URL.Length > maxLength Then String.Format("{0}...{1}", URL.Substring(0, (maxLength / 2)), ...

Why is it bad to use a iteration variable in a lambda expression

I was just writing some quick code and noticed this complier error Using the iteration variable in a lambda expression may have unexpected results. Instead, create a local variable within the loop and assign it the value of the iteration variable. I know what it means and I can easily fix it, not a big deal. But I was wondering why ...

Crystal Report in VB.net

Im creating a report using crystal report in vb.net. The report contained a crosstab which I have 3 data: 1. Dealer - row field 2. Month - column 3. Quantity Sales - summarize field How can I arrange this by ascending order based on the Quantity Sales - summarize field? thanks ...

What value should AutoEventWireup be set to in the page directive in ASP.Net?

I am using C#. By default, when I add a web form in Visual Studio 2008 with or without a master page, the AutoEventWireup attribute is set to true in the page directive. This attribute is also set to true inside the master page master directive. What value should I have AutoEventWireup set to (true/false)? What are the pros and cons o...

Converting a byte() array to a double in VB.Net

Hi, I have this situation. I have a real stored in a varbinary field in a sql 2005 database. As I can't convert a varbinary to a real in sql 2005, I'm trying to do that in vb.net. That field gets stored as a byte() array in a DataTable. Now I would like to read that byte() into a double, or decimal variable. But I don't have much of a ...

What is "DefInstance" and should I remove it from a WinForms app?

I am working on a VB.NET WinForms app that was "upgraded" by Visual Studio (originally 1.0 or 1.1) from VB6 code (which was itself upgraded from VB5). Except for the few new forms I've created since taking over maintenance of this app, all of the forms in the application have a method called DefInstance which allows you to grab an in-mem...