What ‘length’ parameter should I pass to SqlDataReader.GetBytes()

When dealing with varbinary(max), there are two scenarios: the length of the data is moderate the length of the data is big GetBytes() is intended for the second scenario, when you are using CommandBehaviour.SequentialAccess to ensure that you are streaming the data, not buffering it. In particular, in this usage you would usually be writing … Read more

Combining Enums

I believe what you want is a flag type enum. You need to add the Flags attribute to the top of the enum, and then you can combine enums with the ‘Or’ keyword. Like this: <Flags()> _ Enum CombinationEnums As Integer HasButton = 1 TitleBar = 2 [ReadOnly] = 4 ETC = 8 End Enum … Read more

Why are some Microsoft languages called “visual”? (Visual C#, Visual Basic .NET, Visual C++)

I don’t think it has to do with the languages themselves being “visual.” From the Wikipedia article: The term Visual denotes a brand-name relationship with other Microsoft programming languages such as Visual Basic, Visual FoxPro, Visual J# and Visual C++. All of these products are packaged with a graphical IDE and support rapid application development … Read more

Default properties in VB.NET?

Well, the .NET framework does have a notion of a default member. Key ingredients are the DefaultMemberAttribute class and Type.GetDefaultMembers(). In VB.NET, specifying the default member is part of the language syntax: Public Class Sample Private mValue As Integer Default Public ReadOnly Property Test(ByVal index As Integer) As Integer Get Return index End Get End … Read more

Replace string values in list

You have a few issues here: first, strings are immutable, so when you call .Replace you return a new string. Calling n.Replace doesn’t modify n. assigning to n in your anonymous function won’t affect the value that’s in your list. regardless of the above, you can’t change the content of your collection while enumerating it, … Read more

How to add a Browse To File dialog to a VB.NET application

You should use the OpenFileDialog class like this Dim fd As OpenFileDialog = New OpenFileDialog() Dim strFileName As String fd.Title = “Open File Dialog” fd.InitialDirectory = “C:\” fd.Filter = “All files (*.*)|*.*|All files (*.*)|*.*” fd.FilterIndex = 2 fd.RestoreDirectory = True If fd.ShowDialog() = DialogResult.OK Then strFileName = fd.FileName End If Then you can use the … Read more

Create a new thread in VB.NET

There’s two ways to do this; With the AddressOf operator to an existing method Sub MyBackgroundThread() Console.WriteLine(“Hullo”) End Sub And then create and start the thread with; Dim thread As New Thread(AddressOf MyBackgroundThread) thread.Start() Or as a lambda function. Dim thread as New Thread( Sub() Console.WriteLine(“Hullo”) End Sub ) thread.Start()