There is a built in .NET method to capitalize the first letter of each word in a string:
newStr = Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(str)
This is easier than writing the function to do it.
I found this at:
http://www.vbforums.com/showthread.php?557905-Uppercase-first-letter-in-each-word-of-a-string.
This blog is a depository for things I have found regarding VB.NET and C#.NET development (and other things I may need to remember). This blog is primarily for my own reference, but if the information I found is useful to others, then that is great. If others want to contribute with comments or other information, then that is great too.
Thursday, January 24, 2013
Wednesday, December 12, 2012
Automatically Increment Version number for Assembly
I have to look this up every time I do it, so I am posting this link to make it easier to find.
http://www.csharpcity.com/2012/visual-studio-automatic-version-numbering/
To summarize, you have to change the C# assemblyinfo.cs file from:
to just:
The GUI for Assembly Version does not let you make this change.
http://www.csharpcity.com/2012/visual-studio-automatic-version-numbering/
To summarize, you have to change the C# assemblyinfo.cs file from:
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
to just:
[assembly: AssemblyVersion("1.0.*")]
The AssemblyFileVersion entry must not be present.
The version only increments when the project is opened, so it may appear that the version does not increment.
For VB.NET it is similar. Edit the assemblyInfo.vb file and change:
to:
The GUI for Assembly Version does not let you make this change.
Labels:
file version
Tuesday, November 27, 2012
Closing Parent Form from Child Form in VB.NET
The Application.Exit() call can be made in the child form's FormClosed event to exist the app when the child form is closed.
Private Sub Form_Child_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Application.Exit()
End Sub
Private Sub Form_Child_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
Application.Exit()
End Sub
Labels:
VB.NET
Unload Event equivalent in VB.NET
For VB.NET, you can use the FormClosed or FormClosing in place of the VB6 Unload event.
Labels:
VB.NET
Tuesday, April 3, 2012
Can't find Mime Types in IIS 7.5
I was installing a Web Application on IIS 7.5. Everything seems to work until I try to visit some of my pages and they just didn't do anything, no error messages or anything. Strangely, all of the .aspx files worked, it was just simple files like .htm and .jpb that didn't work.
I thought maybe the Mime types were not setup correctly, so I went to see what was defined. I couldn't find the Mime Types option in the IIS Managment Console.
It turns out that the Static Content option under the Http Features (under Server Managers, Web Server roles) was not installed. Installed the Static Content option in Server Manager and everything started working.
I thought maybe the Mime types were not setup correctly, so I went to see what was defined. I couldn't find the Mime Types option in the IIS Managment Console.
It turns out that the Static Content option under the Http Features (under Server Managers, Web Server roles) was not installed. Installed the Static Content option in Server Manager and everything started working.
Labels:
IIS
Wednesday, November 16, 2011
My.Resources in C#
The equivalent of:
My.Resources
in VB.NET is:
Properties.Resources
in C#.
So,
Me.Icon = My.Resources.AppIcon
in VB.NET is equivalent to:
this.Icon = Properties.Resources.App_Icon;
in C#.
My.Resources
in VB.NET is:
Properties.Resources
in C#.
So,
Me.Icon = My.Resources.AppIcon
in VB.NET is equivalent to:
this.Icon = Properties.Resources.App_Icon;
in C#.
Labels:
Resources
Friday, October 21, 2011
Computing RGB composite Color Value in C#
If you still have to deal with the Win32Api in C#, you may need to get the old-style RGB composite color values from a .NET Color value. The ToArgb method doesn't work like you want, so it has to be computed:
Public Function ConvertColorToRGB(col As Color) As Integer
Return CInt(col.R) Or (CInt(col.G) << 8) Or (CInt(col.B) << 16)
End Function
private int ConvertColorToRGB(Color col)
{
return (col.R) | (col.G << 8) | (col.B << 16);
}
If you are using VB.NET, it still has an RGB function to call or:Public Function ConvertColorToRGB(col As Color) As Integer
Return CInt(col.R) Or (CInt(col.G) << 8) Or (CInt(col.B) << 16)
End Function
Subscribe to:
Posts (Atom)