Convert VB to C# or C# to VB

Posted by WorldofCode on Jul 21st, 2010
2010
Jul 21

Handy tool for conveting code inbetween VB and C# or vice versa.

http://converter.telerik.com/

 

Get MP3 file duration/length

Posted by WorldofCode on Jul 20th, 2010
2010
Jul 20

C# code for if you are trying to get the mp3 length or duration of a media file.  You will need to reference Windows Media Player.  Go to Com Add-ins to add the wmp.dll to your project. 

string Duration = null;
WMPLib.WindowsMediaPlayer w = new WMPLib.WindowsMediaPlayer();
WMPLib.IWMPMedia m = w.newMedia(Filename);
if (m != null) {
 Duration = m.durationString;
}
w.close();

Replace line breaks with BR tags

Posted by WorldofCode on Apr 13th, 2008
2008
Apr 13

  In Classic ASP we used to replace line breaks or vbCrLf tags in the following way.

strValue = Replace(strValue, vbCrLf, "<br>")

In ASP.NET it is a bit different.  Now we have the Environment.NewLine command that will determine the coding environment you are running in either VB or C#.  So you can replace the line break command wether it is vbCrLf or /n.

string strValue = strValue;

strValue.Text = strValue.Replace(Environment.NewLine, "<br/>");