Sunday, November 23, 2008

Copy Collections in VB.Net

I learned today that collB = CollA only copies a reference and not the values in the collection. If you try to view data for collB.Item(2) it will show the same value as CollA.ITem(2), but if you later run CollA.Clear() then CollB is cleared as well. To make a copy of a collection you have to copy it item by item instead. See code below for a demonstration.

Code: (Add a button to a form to run code)
Public Class Form1
Dim aa As New Collection
Dim bb As New Collection
Dim cc As New Collection

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
aa.Add("burkA")
aa.Add("burkB")
aa.Add("burkC")

bb = aa
MsgBox("This is collection aa(2) " + aa.Item(2).ToString)
MsgBox("This is collection bb(2) " + bb.Item(2).ToString)

For Each c As String In aa
cc.Add(c)
Next

aa.Clear()
Try
MsgBox(bb.Item(2).ToString)
Catch ex As Exception
MsgBox("CollectionData bb(2)isn't anymore")
End Try
Try
MsgBox("This is collection cc(2) " + cc.Item(2).ToString)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
End Class

Tuesday, November 11, 2008

vb.net disable beep for Enter key in Textbox

You get an annoying beep when pressing enter in a textbox
Disable it with following code:

Private Sub textbox1_KeyPress(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyPressEventArgs) Handles textbox1.KeyPress


If e.KeyChar = ControlChars.Cr Then
e.Handled = True

' Do stuff here when user pressed enter
End If
End Sub

Wednesday, October 22, 2008

VB6 functions replacements in VB.net

Some replacements for us old VB6 developers using VB.net.

VB6 app.path
VB.Net System.AppDomain.CurrentDomain.BaseDirectory()


VB6 rb = Shell("notepad.exe", vbNormalFocus)
VB.Net System.Diagnostics.Process.Start("notepad.exe")

Wednesday, September 17, 2008

Develop in Linux use Gambas



Gambas is similar to Visual Basic which suits me perfectly. I manage to compile the latest version 2.8.2 to night.
I ran into some problem due. There are a good description [for Ubuntu] at
http://gambasdoc.org/help/install/ubuntu?show
But I failed a little when running the package installer script from that page. When you copy it to the terminal you will end up will more than one row so only the first line was processed.
sudo apt-get install build-essential g++ automake autoconf libbz2-dev libgnorba-dev libfbclient2 libmysqlclient15-dev unixodbc-dev libpq-dev libsqlite0-dev libsqlite3-dev libgtk2.0-dev libldap2-dev libcurl3-dev libgtkglext1-dev libqt3-mt-dev kdebase-dev libpcre3-dev libsdl-sound1.2-dev libsdl-mixer1.2-dev libsdl-image1.2-dev libsage-dev libxml2-dev libxslt1-dev build-essential libbonobo2-dev libcos4-dev libomniorb4-dev firebird2.0-dev librsvg2-dev libpoppler-dev libpoppler-dev libpoppler-glib-dev libasound2-dev libartsc0-dev libesd0-dev libesd-alsa0 libdirectfb-dev libaa1-dev libarts1-dev kdelibs4-dev libffi4-dev libxtst-dev gettext

Copy the line above to avoid the line-feeds or copy it to a text editor first and remove the
line-feeds there.

Also read the Readme file in the /usr/src/gambas2-2.8.2 directory,
there is a good tip if the compiling fails (run ./reconf)

There is also a different make install commando: su -c "make install"
(the installation guide used: sudo make install).
I'm not the expert but su -c "make install" worked for me.


Thursday, September 11, 2008

Copy your ipconfig data the easy way

Run following command from Start->Run

cmd /k ipconfig /all > %temp%\ip.txt && notepad %temp%\ip.txt && del %temp%\ip.txt && exit

A notepad window will appear showing the ipconfig data.

Friday, September 05, 2008

What is lurking in svchost.exe

Run following command from Start->Run
cmd /k tasklist /svc /fi "IMAGENAME eq svchost.exe" > %temp%\svc.txt && notepad %temp%\svc.txt && del %temp%\svc.txt && exit
(works on XPpro, Vista I guess)

A notepad window will appear showing the services svchost.exe are running.

Friday, January 25, 2008

VB Express 2005, Copy to Clipboard

Dim dummy As String
dummy = "This is copied to the clipboard, enjoy" & vbCrLf & "A second row"
Clipboard.Clear()
Clipboard.SetText(dummy)

End blog

MySQL to MariaDB

 Here is a good description how to migrate to MariaDb MySQL to MariaDb Example of how to dump data from MySQL port=3307: mysqldump --user=ro...