Monday, September 17, 2007

How to show screen saver in VB.NET

Found this on Codeproject.com.
Very easy and very good indeed.

Dim regkey As Microsoft.Win32.RegistryKey
regkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Control Panel\Desktop")
Dim Prs As New Process
Prs.StartInfo.FileName = regkey.GetValue("SCRNSAVE.EXE").ToString
Prs.Start()


Enjoy IT!

Wednesday, August 15, 2007

Location of Form in VB.NET

I wanted to change the location of a form where it shows when it loads.
Just a simple thing, and i had done it many times, but i was trying

dim f as new MyForm
f.location = new point(-1000,-1000)
f.showdialog()

but it was not working. Couldnt figure out this a day before. After i came to office today, i was looking at some other things, and i found the solution.

just had to add a new statement before showing the form.

f.StartPosition = FormStartPosition.Manual

then it shows in the correct location.

Enjoy IT!

Monday, April 30, 2007

How to make a math expression evaluator for VB.NET

Just found a C# one, and converted it for VB.NET

Private Function CalculateEval(ByVal command As String) As String
Try
Dim myCodeProvider As New CSharpCodeProvider
Dim cp As CompilerParameters = New CompilerParameters()
Dim TempModuleSource As String = "namespace ns{" + "using System;" + "class class1{" + "public static double Evaluate(){return " + command.ToString + ";}}} "
Dim cr As CompilerResults = myCodeProvider.CompileAssemblyFromSource(cp, TempModuleSource)
If (cr.Errors.Count > 0) Then
Throw New ArgumentException("Expression cannot be evaluated, please use a valid C# expression")
Else
Dim Methinfo As MethodInfo = cr.CompiledAssembly.GetType("ns.class1").GetMethod("Evaluate")
Return Methinfo.Invoke(Nothing, Nothing)
End If
Catch ex As Exception
End Try
Return ""
End Function

Enjoy IT!

Thursday, April 05, 2007

VB Helper: HowTo: Change the color of an MDI parent form's background in VB .NET

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

' Set the color in the MDI client.
For Each ctl As Control In Me.Controls
If TypeOf ctl Is MdiClient Then
ctl.BackColor = Me.BackColor
End If
Next ctl
' Display a child form.
Dim frm As New Form2
frm.MdiParent = Me
frm.Width = Me.Width \ 2
frm.Height = Me.Height \ 2
frm.Show()
End Sub

Enjoy IT!

Saturday, March 24, 2007

How to convert a String to a Dataset

dim StringXML as string = "
00racs
"

Dim ds As New DataSet

Dim StringReaderString As System.IO.StringReader = New System.IO.StringReader(StringXML)

ds.ReadXml(StringReaderString)

Now you have a dataset.


Enjoy IT!

Saturday, February 24, 2007

How to change keyboard layout at runtime

I had a problem, in which i had to change the keyboard from english to arabic and from arabic to english at runtime.

At first i was doing it with SendKeys.Send("+%") which is Alt + Shift. But this was not effiecient at all.
So for .Net, it can be done easily with


InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(New System.Globalization.CultureInfo(&H409))

where &H409 is the Hex for English and &H401 is for arabic.

Loop through InputLanguages in your system.

For Each s As InputLanguage In InputLanguage.InstalledInputLanguages
MsgBox(s.LayoutName)
Next


Enjoy IT

Monday, February 19, 2007

The purpose of *.vshost.exe: Now we know

I have been wondering what the purpose of *.vshost.exe was when I ran apps from Visual Studio 2005.

Now I know. It's actually quite cool. Check it out:

VSHOST -- the Hosting Process

What is "vshost"?

This is the "hosting process". It is created whenever you build a project in the Visual Studio 2005 IDE. Its purpose is to provide support for improved F5 performance, partial trust debugging, and design time expression evaluation.

Should I deploy the "vshost" files with my application?

No. The "*.vshost.exe" and "*.vshost.exe.config" files are only for use in the Visual Studio 2005 IDE. They should never be run directly, and they shouldn't be deployed with your application.

Monday, February 05, 2007

Edit and continue won't work with vs2005?

Autodesk - Discussion Groups - Edit and continue won't work with vs2005?

For my problem, this didnt help, even after reading the entire page. So how i solved my problem.
Long time ago i had changed something in the settings of the Project Properties -> Debug -> Enable unmanaged code debugging. I have checked this. So now after reading this, i just out of curiousoty unchecked this, and VIOLA!!!! i could work with Edit and Continue in debug mode.

You see, a very big problem (at least for me) and a very small solution.

Try IT!

Sunday, January 28, 2007

Getting field names of table and view in SQL Server

select
distinct sc.[name]
from
syscolumns sc inner join sysobjects so on sc.id = so.id
where
(so.xtype='V' or so.xtype='T') and so.category = 0
order by
sc.name

Best Smartphones/tech of 2019

So I was looking for the best tech of 2019. Here it goes: New Pixel 3 XL Google - Pixel 3 XL with 64GB Memory Cell Phone (Unlocked) - ...