Tuesday, November 24, 2009

Shared file between project types

As requested, unfortunately over a month ago (sorry GhostInAK), I am going to cover how to use the same file for two different project types particularly VB.Net Windows Mobile and a VB.Net Windows Forms.

I'm going to start with 1 solution, consisting of two projects a Windows Mobile and a Windows Form, both in VB.Net.

Now that the solution has both projects, I'm going to right click on the solution and select "Create Solution Folder" (You can also click the "Add New Solution Folder" at the top of the Solution Explorer). Change the name of the folder as needed.

After the folder is created, I'm going to create a file inside of this folder using the same technique to create any new class file (Right click on the folder, select Add, select New Item and choose the same language for the file (C# or VB)).

Once the file has been created, close the code document.

Right click on one of the projects and select Add, then Select Existing Item.
In the Add existing item dialog box, navigate to the solution folder (move up 1 level and you should see the file you created inside of the solution folder). Select this file and click the arrow next to the Add button, then select "Add As Link". Repeat this steps for each project.

After this done, I can now begin writing code that will work with both of the projects.

In order to edit the document in the mode that it will be used for, we must open it from within that project. Thus if you're adding mobile code, you need to open the mobile projects link of the file. If you need to then edit the desktop code, save and close the document before opening the desktop version of the file.

Most items will work in both frameworks, but for those that only work in the desktop environment, wrap the code with the conditional statement

#If Not PocketPC Then
DesktopCode
#End If


If it only works in the mobile environment, wrap the code with the conditional state

#If PocketPC Then
MobileCode
#End If

Note: These conditional statements can be used around classes, procedures and inside of the procedures so long as the process flow isn't broken. The following examples will work properly.

Dim s As Integer = -1
If s = 0 Then
ElseIf s = 1 Then
#If PocketPC Then
Else
#End If
End If


#If Not PocketPC Then
Sub WorksOnlyOnDesktop()
End Sub
#End If


In conclusion, having the file split and used by two different project types isn't too terrible of an idea so long as the code inside of it is properly tested to ensure that there wont be any errors from either the desktop or mobile environment. At some point, one of the projects may use the file in a completely different manner than the other project, in which the file should be eliminated and code migrated to that project.

If there are any questions, I can attempt to resolve them, hopefully a lot sooner than this request. (Sorry again)

Kids these days

I guess I'm just "old school" but I'm becoming more and more agitated by kids these days.

It seems that every young programmer decides that speaking in incomplete sentences using text messaging language will allow other people to understand what they're saying.

I give the following example from DaniWeb.com (I had a REALLY good example from StackOverflow, but I can't find it now :-( )

When did programmers become so lazy? I guess I understand if you're in a chat room (IRC, AIM), but this is ridiculous. How is anyone suppose to understand what they're asking?



I know I'm just ranting, but I figured it has to bother someone else too.

Friday, March 20, 2009

Time Zone Class for .Net 1.1

Thanks to a configuration required for a customer at work, I had some fun attempting to track down a .Net 1.1 version for Time Zones. Ya know, those things that drive our life that Microsoft some how explicitly left out of the .Net 1.1 framework.

At any rate, I finally got some help from Kulrom at VBCity.com and put together the following piece of code, hope it helps someone.

Essentially when you call GetTimeZones it populates a combo box with all the timezones listed in the registry as well as populating a collection which holds this information to be used later. It's all rather pretty. The funcationality not necessarily the code.

Well, enjoy!
The code is in my post in the thread mentioned earlier at VBCity.com

New Computer

So, I finally did I broke down a bought a new computer. It's not a fantastic computer like many people would want but it's much to fast for me to handle.

Currently, I have a multi-boot sitatution on my hands. I'm running Win XP Pro x86, XP Pro x64, XP Vista Ultimate x86 and Win 7 Beta 7k. XP Pro x64 is what I'm working on as we speak... It's exciting, finally can put the full 8 GB of ram to good use for vertual machines. I'm planning on adding a Linux install, but I haven't decided which, hence the need to run the virtual machines... Well, that and I want to write applications to run in both x86 and x64.

Well, the specs of my machine are as follows:
  • Intel Core 2 Quad Q9550 2.83 GHZ
  • Asus P5Q Pro mobo, which I think I should've gone with a different one, but I'm not a hard core gamer, so no worries.
  • 4X2 GB (maximum for mobo, 1 reason to get a different one) Corsair DDR2 1066 (Mobo can support 1200, but I'm semi-cheap)
  • 3X 500 GB Western Digital Caviar Black in a Raid 5 and Raid 0 spec thanks to the wonders of the Intel Matrix.
  • A 1GB Sapphire Radeon HD4850.
  • A Corsair 620 W PSU, will have to upgrade to an 850 to be on the safe side when I get all 8 disks (far future, after school before I have another Raid 5)
  • And a lowly cheap ass dvd burner that was $27. :-)
  • All stuffed into a Lian Li case.
Let me just toot my horn, I like it. Can buy the same thing for $300-$400 less, but I'm content. :-)

Friday, January 9, 2009

Access Context Menu Strip

So, I had a problem with a context menu not having a filter for label and text box, similar to the menu in any MS Access table or query. So I made one. Some of the functionality is incomplete, but it seems everyone is looking for it. There is a Filter For label and text box (a user control) and the context menu is a custom control.

There are a few side notes:
  • The Cut,Copy, Paste are all not valid because I have no use for them in my application. Although there is code for Copy, but couldn't figure out all the logic.
  • The Filter For covers integers, booleans and strings, all based on the columns data type and the information stored in the first row of the column. The date data type and dbnull values have not been evaluated in that procedure. But I don't have a problem with other people doing the work and returning with the answer. :-)
  • This only currently works with data grid views that have data tables as the data source. All of the filtering is done by the control and the form does not need to handle any of those events.
  • The solution which is zipped, as well as the DLL, were both written in VB .Net 2.0 using Visual Studio 2008. Adding the project or at least the code files to your project will give you the same functionality as referencing the DLL.

Feel free to download it and let me know what you think.

Additional, link: http://tinyurl.com/84288z