vb.net

Preserving NULL values in a Double Variable

Hi, I'm working on a vb.net application which imports from an Excel spreadsheet. If rdr.HasRows Then Do While rdr.Read() If rdr.GetValue(0).Equals(System.DBNull.Value) Then Return Nothing Else Return rdr.GetValue(0) End If Loop Else I was using st...

Can you use .Contains(string) with a Select Case Statement?

Is there anyway I can build a Select statement that uses the Contains function? Like this: Select commentStr Case commentStr.Contains("10") Case commentStr.Contains("15") ...

Missing Quote for String in Locals

I read in a Byte Array generated from a function called from an external DLL file and then converted (encoded) it into a String. In the Locals window (shown below), msg does not have a trailing double-quote. Is this a bug, glitch, or a sign something is wrong? Code: Dim msgC(32) As Byte Dim msg As String, length As Integer = ...

ListView ToolTip only in First Cell - VB.NET

I'm adding a ToolTip to a ListViewItem. However, the ToolTip only shows up when the user hovers over the first cell in the row to which the ToolTip has been applied. MyListViewItem.ToolTipText = "Important Message" The only other code I have related to ToolTips is this: MyListView.ShowItemToolTips = True Any idea how I can make th...

Problem sending mail with simple .net application. Server refusal error.

I have a very simple .net application for testing SMTP on .net. But i am receiving this weird error. "System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused i...

Optimizing division/exponential calculation

I've inherited a Visual Studio/VB.Net numerical simulation project that has a likely inefficient calculation. Profiling indicates that the function is called a lot (1 million times plus) and spends about 50% of the overall calculation within this function. Here is the problematic portion Result = (A * (E ^ C)) / (D ^ C * B) (where A-C...

Me As Child Type In General Function

I have a MustInherit Parent class with two Child classes which Inherit from the Parent. How can I use (or Cast) Me in a Parent function as the the child type of that instance? EDIT: My actual goal is to be able to serialize (BinaryFormatter.Serialize(Stream, Object)) either of my child classes. However, "repeating the code" in each ch...

Constructing an object and calling a method without assignment in VB.Net

I'm not entirely sure what to call what C# does, so I haven't had any luck searching for the VB.Net equivalent syntax (if it exists, which I suspect it probably doesn't). In c#, you can do this: public void DoSomething() { new MyHelper().DoIt(); // works just fine } But as far as I can tell, in VB.Net, you must assign the helper ...

vb.net master page needs to save data in session after calling pages change

i have 1 master page with 5 dropdownlists on it. The thing is, the master page has href's to aspx pages that use this master page as pagebehind. now lets save i am in page1.aspx with master1.master as pagebehind. If i select couple of dropdownlists, and then click on an href, the whole master page reloads. how do i catch this in session ...

Load richtextbox from memorystream. WPF/VB>NET

Hi, I have some trouble with loading a richtextbox from a memorystream. I have some data in a database table stored as a byte array, I convert it to a string and load it into a memorystream and then I want to load that memory stream in the richtextbox. The application breaks on Dim tr As New TextRange(rtbTemplate.Document.ContentSta...

WinForms / .Net interactive world map - how?

In a CD collection program, I have each artist's country of origin stored in the main database and want to display a map of the world which: Colour-codes each country depending on the number of CDs by artists in that country Allows clicking on each country to filter a list of CDs to only ones by artists in that country This is a heav...

How to get os version of remote computer using computer name or ip address?

I tried to get os version of remote computer using ip address with WMI ,It shows "RPC server unavailable" error. If anybody have solution for getting remote system information without WMI in vbnet, Please help me ...

Resizing the Array

How can I resize the two dimensional array size without affecting its value? ...

Prevent automatic selection on textbox focus

Hello, When you use a tab key to select a textbox, all text in it is automatically selected. What's the easiest way to prevent this from happening? (Setting the selection to none in Enter or GotFocus events doesn't work) Thanks (-: ...

In VB.net websites, VS2008 ALWAYS uses space indentation for new files

So, I've changed my settings in Tools | Options | Text Editor, for All Languages, Basic, and C#, to having Block indenting, and 'Keep tabs'. I've also tried this with Smart indenting too. Now, although once I start editing a file, its auto indentation is done with tabs, when I create a new web form in my ASP.net website, VS2008 insists...

settting up Control properties in between postbacks is not working

I am settting up control propertis on page load. Like visiblilty of control depending on loaded data. And very simple setting up images to button controls. For page load it works fine but on postback these values are not set back. This is my code. When it’s a postback btnSecurityQA image is missing and visibility of all following control...

What is CDbl doing?

I had until recently been under the impression that the CDbl(x) operation in VB.NET was essentially a cast (i.e., the VB equivalent of (double)x in C#); but a recent discovery has revealed that this is not the case. If I have this string: Dim s As String = "12345.12345-" And I do this: Dim d As Double = CDbl(s) d will be set to th...

Can not get selectedindex with Listbox in VB.NET 2008

Hi, I click on items in my listbox and then hit a submit button, but when istep through my button_clicked code it doesn't detect any selectedindex. All controls are in the same form and there are no panels. Why can't I detect what items were clicked on in the listbox? Thanks! ...

Declaring variables with New DataSet vs DataSet

What is the impact of creating variables using: Dim ds as New DataSet ds = GetActualData() where GetActualData() also creates a New DataSet and returns it? Does the original empty DataSet that was 'New'ed just get left in the Heap? What if this kind of code was in many places? Would that affect the ASP.NET process and cause...

vb.net date format from textbox > MS SQL query

Hi folks, I have a date column in a DB tabel that I want to query using a date taken from textbox.text. the user selects a date from the calendar in the format dd/MM/yyyy. I want to use that date to put into a query. How do i format the date to be able to query the database? Dim datefrom As String =txtDateFrom.Text Dim dateto As St...