vb.net

Form load Event fires twice, using Interop Forms Toolkit

I've been following a codeproject article on using the interop forms toolkit (basically a way for developers to slowly upgrade their VB6 projects to .net by allowing .net components run in VB6) http://www.codeproject.com/KB/vb-interop/VB6InteropToolkit2.aspx While the .NET form is working fine in all other testing projects and environm...

Help: MySQL adapter.fill(dataset) Error

I'm connecting to a MySQL database using the MySqlClient class. When I try to fill a fill a Data List with the Data Set I get an error: #42000You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax Heres the code I have in VB.net to fill the data list. Dim strConn A...

Getting System.Net.Mail to read from app.settings?

In ASP.NET, I can just put my mailSettings in web.config and then System.Net.Mail.SmtpClient's default constructor will read them. In a regular VB.NET project, not ASP.NET, I thought I could just put mailSettings in app.config. However, SmtpClient() doesn't appear to read settings from app.config. Is there a step I'm missing in order ...

LINQ-to-List and IEnumerable issues

I am querying an HTML file with LINQ-to-XML. It looks something like this: <html> <body> <div class="Players"> <div class="role">Goalies</div> <div class="name">John Smith</div> <div class="name">Shawn Xie</div> <div class="role">Right Wings</div> <div class="name">Jack Davis</div> ...

Programatically ejecting and retracting the CD drive in vb.net or c#

Is there any way to do so? I know its possible to programmatically eject/retract the cd drive SOMEHOW, cause Roxio does that when it prompts me to insert a disk. Either c# or vb.net is preferable, but c and c++ are okay too as a last resort. I am nearly positive there is some way to do this, I just don't know the methods to call. I do...

datetime.tostring issue in vb.net

Hello, I have a variable for startdate as shown below. Dim startDate as Datetime startDate = Convert.ToDateTime(datepicker1.text).ToString("dd-MMM-yyyy") In the immediate window if I try Convert.toDate(datepicker1.text).toString("dd-MMM-yyyy") it is showing date as 29-Sep-2009 but the value of startDate is 09/29/2009 I really don't...

Creating a date from a text string - VB.Net

I having a problem converting a string into the date format I need. An example of the string I'm trying to convert would be 215056081909. I would like to convert that string into 08/19/09 21:50:56. The code listed below is what I'm trying to use for the conversion process. When I run the code I'm getting the error below and I'm pre...

C# - How do I read and write a binary file?

How do I read a raw byte array from any file, and write that byte array back into a new file? ...

VB - How do I read and write a binary file?

How do I read a raw byte array from any file... Dim bytes() as Byte ..and then write that byte array back into a new file? I need it as a byte array to do some processing in between. I'm currently using: To read Dim fInfo As New FileInfo(dataPath) Dim numBytes As Long = fInfo.Length Dim fsAs New FileStream(dataPath, FileMode...

How to store errors in sql table or log file if there is an error in sending email

Hi, I am using VB.net code and SQL server 2005. I am havng below code for sending email in my vb.net code. Protected Sub ibtnSendInvites_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ibtnSendInvites.Click Try Dim emailList As New List(Of String) For Each curRow As GridViewRow In Gr...

Access webcam and microphone input in VB.net

How can you access the webcam and microphone in VB.net, assuming the user even has one? I fail to see a My.Computer.Webcam or My.Computer.Microphone, both of which would probably have been a nice addition. Thanks for the help! If there is no easy method for doing this, what is the name of the driver that handles this and what methods s...

Execute commands like in command prompt in vb.net

I know of the Shell method to run files, but how can I execute normal command prompt commands like nslookup, and capture the output as a string? Thanks for the help! Every google search has just turned up the shell method >_> ...

Doing math in vb.net like Eval in javascript

Is there any way to parse a string in vb.net (like, built in methods), that can do math like Eval can? For example, 3+(7/3.5) as a string would return 2. I am not asking for you to code this for me, I just want to know if there is a built in way to do this, if there is not I will code it myself. I can wager that it would not be able to...

Why null == myVar instead of myVar == null?

What the title says! I see it from times to times and I'd like to know why. Is there any difference at all? ...

[Conditional("Debug")] + #if DEBUG

I have seen in Debugging .net 2.0 Applications the following code [Condictional("DEBUG")] void AssertTableExists() { #if DEBUG ... #end-if } Is there any reason to use the #if directive? I mean, from what I understand the method will only be called if the DEBUG is defined, so I don't see a point in having the #if in th...

Tricky replacements in vb.net

I want to replace the text in a string "Sin()" with the computed value for Math.Sin() where is...anything. My problem: The string can have more than one right parenthesis. Also, since it is performing mathematical operations, it would have to know how to do the innermost ones first. Obviously, there is not a built in method for comput...

Declaring Enums across derived classes

Hi, I am developing a program in VB.NET. I have an enum called PriceType that is declared in a super class ItemPriceBase. There are 3 classes that derive from ItemPriceBase - ItemPriceMeasured, ItemPriceNDI and ItemPriceExtraCost. The subset of PriceTypes for these classes are totally unique from each - Measured prices are 1 to 6, NDI...

Creating Tables in Word Programatically

I am generating tables and writing them to word on the fly. I do not know how many tables there will be each time i write the data to word and the problem I am having is the second table is written inside the first cell of my first table. If there was a third table it is put inside the first cell of my second table. Is there a way to mo...

How to Synchronise(update) Windows and Web Application Databases

I am having an application in both windows and web domains.The web part of it have only limited features compared to it's windows counterpart.But for my case (an appointment fixing module which is done using both domains),I want both databases to update with the other database.Can anyone help me please. ...

How to get last inserted identity in Formview Inserted event using VB.net

Hi, I am using VB.net (FormView and ObjectDataSource) and Sql Server 2005. I want to get last inserted @@identity in table on FormView1_ItemInserted Protected Sub FormView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewInsertedEventArgs) Handles FormView1.ItemInserted End Sub My issue is that I w...