vb.net

When should I implement IDisposable?

What is the best practice for when to implement IDisposable? Is the best rule of thumb to implement it if you have one managed object in the class, or does it depend if the object was created in the class or just passed in? Should I also do it for classes with no managed objects at all? ...

Trouble with DynamicHorizontalOffset and asp.net menu server control

I have a horizontal asp.net menu control on my web site and I want to move the dynamic menu to the right by a few pixels to align it correctly with my static menu items. My dynamic menu has two levels. When I set the DynamicHorizontalOffset to say 10, the first dynamic level moves to align correctly with the static items, but obviously ...

VB.net Net after load event?

I need some way of knowing when a form has finished loading. My reasoning is I have a 2nd form that is loaded when this form loads. The code for this is called from form1.load. Form2 is currently being displayed behind form1 as I am guessing form1 calls an activate or similar at the end of the load so any Activate, BringToFront etc ...

SQL Server Profiler Implementation Using C#/VB.net

I wish to implement Sql Server Profiler in a C#/VB.net application. Does anyone have a good example of how to do this? I have searched on Google but didn't find a good working example. I don't have Sql Server Profiler on my system and also don't have Sql Server (it is on a different system). How do I create Profiler for my self? ...

ToolStripComboBox + objects default string value

I am using a ToolStripComboBox to list some data. I am populating this combo with some custom objects: For Each obj As myObject In myObjectList myToolStripComboBox.Items.Add(obj) Next This works great except the text displayed in the combo is the name of the object class. I can understand why and realise that I need to do somethi...

Can you make VB.NET compilation as strict as C#?

In VB.NET, it is entirely possible to pass an integer as a string parameter to a method without calling .ToString() - it's even possible to call .ToString without the ()'s. The code will run without a problem, VB will interpret the integer as a string without having been told to. In C#, these would cause compilation errors - you are req...

How do I convert the below PHP code to VB.NET?

How do I convert the below PHP code to VB.NET? <?php $X_HOST ="foo.com"; $X_URL = "/index.php"; $X_PORT ="8080"; $X_USERNAME = "foo"; $X_PASSWORD = "bar"; $s_POST_DATA = "Channel=UK.VODAFONE"; // Channel $s_POST_DATA .= "&Shortcode=12345"; // Shortcode $s_POST_DATA .= "&SourceReference=3456"; // Source Re...

Windows Service not able to access a file in VB.net in Windows 2003 Server

Hello, I have a .net Windows Service developed in VB.net. I have a settings file in the root directory called Connections.XML and I am setting the basedirectory as below System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory) Dim _path As String = System.AppDomain.CurrentDomain.BaseDirectory() ...

how to reload windows a form without closing it using vb.net

hey guys, can u please tell me how i can reload a windows form without closing it.thanks ...

How can I use CodeDom to create a decimal constant?

I have this function in my generator. Private Sub AddBoundedValue(ByVal boundedValue As Object, ByVal type As CodeTypeDeclaration, ByVal numericType As Type, name As String) If boundedValue IsNot Nothing Then Dim constant As New CodeMemberField(numericType, name) constant.Attributes = MemberAttribut...

value of type 1-dimensional array cannot be converted to system.collections.bitarray

Hello, I have a function to create a pdf which should return bitarray. Below is the code Public Function GenPDF() As BitArray Dim pdfdoc1 As BitArray Dim doc As New Document(iTextSharp.text.PageSize.LETTER, 10, 10, 42, 35) Try Dim MemStream As New MemoryStream Dim wri As PdfWriter = PdfWr...

Anonymous object properties by string?

How can I instantiate an anonymous object while passing the propertynames and values as string? new With { .SomeProperty = "Value" } new With { ".SomeProperty" = "Value" } //something like this? :) ...

SQL syntax error in Update statement VB.net

Hi, Im getting a strange syntax error when I run this in VB SQLString = "UPDATE Login SET Password = '" + PasswordTextBox.Text + "'" SQLString += " WHERE UserName = '" + UserNameTextBox.Text + "'" The Username is checked before getting to this part and is definitly in the db. It gives an exception saying syntax error ...

WebBrowser DrawToBitmap other methods?

I am trying to capture the content of the WebBrowser control. DrawToBitmap() would work perfectly, but it is not supported in documentation for the WebBrowser control. I have been trying to find another way to capture the contents of the WebBrowser control and save them to a local image file. Anyone have any workarounds or other metho...

Best practices for organizing .NET P/Invoke code to Win32 APIs

I am refactoring a large and complicated code base in .NET that makes heavy use of P/Invoke to Win32 APIs. The structure of the project is not the greatest and I am finding DllImport statements all over the place, very often duplicated for the same function, and also declared in a variety of ways: The import directives and methods are s...

What should happen when a reference is deleted?

I have a vb.net 3.5 application which references a dll (abc.dll, also in .net 3.5) This dll is accessed by the application from time to time. If at anytime during execution, if I delete the dll, I expect the application to throw an error the next time it tries to use a class from the dll. But, this is not the behaviour I see. If I delet...

Obtaining reference to Class instance by string name - VB.NET

Is it possible using Reflection or some other method to obtain a reference to a specific class instance from the name of that class instance? For example the framework for the applications i develop heavily uses public class instances such as: Public bMyreference as MyReference = new MyReference Then throughout the application bMyRef...

Screen Scraping - still not working

I have browsed through many posts on this and have tried some of the suggestions but still not understanding it fully. I would like to scrape html pages that have some script running that usually executes the script to display a link after clicking. Some mentioned firebug and others talked about reverse engineering the code I need. But ...

How can a property resolve its own name and type with reflection?

Is there a way for a property to access its own name and type at runtime using reflection? I want to access this info without hard coding the name or index of the property in the class. Simple Example Code: Private ReadOnly Property MyProperyName() As String Get Console.WriteLine((Get Current Property Info).Type.ToString) ...

Porting VB6 app to VB.Net: Can anyone ballpark how much effort this is?

In 2002 I did a pretty large VB6 app for a client. It used a lot of UserControls and a 3rd party menu control (for putting icons next to menu names). It had dynamically "splittable" panels, TreeViews with multi-state checkboxes, etc. A very rich UI. My total time on the project was about 500 hours, which the client graciously let me spre...