vb.net

How to group enums, structures and subclasses in classes?

I've heard bad things about overusing regions but when adding enums to my classes I put them into a #region "Enums" at the end of the class, and do the same with structures and even subclasses. Is there a better/standard way to go about grouping such elements on classes? (Note: this is tagged C#/VB but maybe the same situation exists f...

Can I use an extension method with a Structure in VB.NET?

I am wondering whether I can use DataContractJsonSerializer to serialize a Structure type, or does it have to be a reference/Class type? I have the following code: <Extension()> Public Function ToJSON(ByVal target As Object) As String Dim serializer = New System.Runtime.Serialization.Json.DataContractJsonSerializer(target.GetType...

What is wrong here? I'm confused... ToJSON Extension Method

Given the following declaration: <Extension()> Public Function ToJSON(ByVal target As Object) As String Dim serializer = New System.Runtime.Serialization.Json.DataContractJsonSerializer(target.GetType) Using ms As MemoryStream = New MemoryStream() serializer.WriteObject(ms, target) ms.Flush() Dim bytes ...

Interfaces in .Net

Hello everyone! I would like to use the same code for copying files to an FTP server, and through USB. I've already written some code, which as of now uses functions from the System.IO namespace. To minimize code duplication, I've listed the functions which I need from the system.IO namespace, and I was thinking of designing an interfa...

Sync Framework 2.0 Error: The specified change tracking operation is not supported.

I'm fairly new to the MS Sync framework and have been beating my head against the wall for about four hours now to no avail. I'm simply trying to sync my databases (one "master" SQL Server 2008 with a SQL Server CE, the client) with: Dim syncAgent As DataCacheSyncAgent = New DataCacheSyncAgent() Dim syncStats As Microsoft.Synchronizati...

how can i dynamically change the connection string

I am using vb.net and SQL server 2005 I have a project with database classes which are generated from database objects. That is I add a dataset to the project and drag and drop a database object onto it. The problem with this is that I have to give a connectionstring which is stored in the code. This is ok while developing the applicati...

VB.NET: Populating a list in Linq

Assume I have the following XML file: <Movies> <Movie ownerName="Ryan"> <Title>The Lord of the Rings Trilogy</Title> <Title>Saving Private Ryan</Title> <Title>etc</Title> </Movie> <Movie ownerName="Rynina"> <Title>Foo</Title> <Title>Bar</Title> </Movie> </Movies> Wh...

Object variable or with block variable not set error vb.net

I am populating combo box from database. In debug i can see that the combo box has been populated . here is the code Private Sub ComboID_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboID.SelectedIndexChanged Dim data(21) As String Try t_code.Text = ComboID.SelectedIt...

[VB.Net] Trim images (Crop to remove all blank areas)

Hello world! To reduce the size of some images I have, I'd like to remove the white paddings that some have. The idea would be that if one has large white areas on the borders, then those can be cropped to save some space. Any idea? Thank you, CFP. ...

Problem with toolstrip renderer in VB.net

Hello, I'm using the toolstrip renderer in vb.net, found the source over at: http://63.236.73.220/showthread.php?t=539578 Now, it works great however the style doesn't seem to stick when I click a button on the toolbar. I use a toolstrip sort of like tabs, and what I'd like is if a toolstrip menu is clicked the style stays so I can vis...

Differences between 32 and 64Bit .NET (4) applications

Hi there, what are the differences between 32 and 64Bit .NET (4) applications? Often 32Bit applications have problems running on 64bit machines and conversely. I know I can declare an integer as int32 and int64(certainly int64 on 32Bit systems make problems). Are there other differences between programming an 32 OR 64Bit or a both 32 AN...

Web.Config file corrupting on publish

So I've just started up my most recent website: http://EpicClanWars.com and it would seem that every 5th or 6th time I publish my project out of VS 2005 the Web.Config file corrupts and loses its connection string to the database and a nasty exception gets thrown stating that the web.config file does not contain the connection string th...

How to reverse this algorithm to get back the original text?

Can anyone please explain with the easy coding how to reverse this algorithm so that I get back the original text string? Public Function CreateIntChecksum(ByVal s As String) As Integer Dim r As Integer = 0 For i As Integer = 0 To (s.Length() - 1) Dim bchar As Byte = Convert.ToByte(s(i)) r = bchar + ((r << 5) - r...

Bind query result to datatablde

Sample in C# or VB.NET are welcome. I want to bind the following query result to datatable: Dim query = From c in db.Customers _ Where c.Status = "Active" _ Select c.CId, c.FirstName, c.LastName, c.Email Thanks. ...

Storing multiple images in SQL Database

I'm trying to store three images from a form (PictureBox's) into a SQL Database (MSSQL2008) I'm new to programming and having a little difficulty simplifying my code. The below does what I want but is clearly inefficient. Any pointers on what to change to improve this? Private Sub SaveImages() Dim ConStr As String = "Data Sourc...

Check keyvaluepair againt existing values in list of keyvaluepair

Hello, How can I check a new KeyValuePair against an existing list of KeyValuePair ? I want to compare for a condition to include or exclude the item. I am using vb.net 3.5 it is a nested For loop and I am deleting a datarow on the result of the condition args = (existing list of KeyValuePAir) For Each datarow As DataRow In ds.Tables...

Visual Studio - Change datasource after initial database server is down?

Ok, so I've got this Visual Studio 2008 Project I was working with about a year ago perhaps. And this project had a datagrid that was linked to an external database running on a server off the internet. Now, this databinding was all done using Visual Studio 2008's built in features. But how can I now change the binding to a different se...

LINQ to SQL join two tables to select parent table twice based on two different columns from child table

I'd like to get suggestion in both C# and VB.NET I have two tables Employees and CafeLogs. Some employees can be cashiers and also customers at the Cafe shop. Table structures: Employees: EmployeeId(PK) , FirstName, LastName CafeLogs: LogId (PK), CashierId, EmployeeId, Value, => CashierId and EmployeeId are the data from column Emp...

How to use the return value of a VBScript function into a VB application?

I'm developping an ASP.NET application, and I need to use an old VBScript file that would be really hard to translate into pure VB in a VB function. This VBScript is supposed to return an array that I'd like to use it in the VB function that called it. How could I call the VBScript function in my VB application and use the value it ret...

How to receive PostMessage/SendMessage in VB.NET ?

Hi, I am trying to write a small plugin for eventghost for one of my software (audio player). EventGhost can send SendMessage or PostMessage messages to control other apps. How can I receive such messages in a VB.NET app? Any Ideas? Thanks! ...