Wednesday, March 9, 2011

Using style sheet to make text center with HTML

Using style sheet to make text center with HTML

in style sheet (.css) file , you define class like this

div.div_center{
   width:800px;
   left:50%;
   margin: 0px auto 0px auto;
}

to use like this

...
<body>

<div class = "div_center">
    ... center stuff..
</div>

</body>

Tuesday, March 8, 2011

WPF Datagrid and datatable in vb.net

WPF Datagrid and datatable in vb.net


To assign datatable to WPF datagrid we simple use property "defaultview".

sample in vb.net:


dim mdt as new system.data.datatable
mdt.columns.add("Column1")
mdt.columns.add("Column2")

mdt.rows.add("id 1", "text 1")
mdt.rows.add("id 2","text 2")

mdt.rows.add("id 3","text 3")


mydatagrid.itemssource = mdt.defaultview

Monday, March 7, 2011

Important of the log file in programming


Important of the log file in programming

What's log file?

Log file is the file program create during it operation and process, this log file is very useful for developer to check and debug the big program.

We can integrate log file very easy through the system.file.io

Sample in vb.net


Private mlogst as system.text.stringbuilder
'function to create log file.
Sub writelog(mlog as string)
  
     Dim logfile as string = "c:\temp\log.txt"
  
     Try
       
          'mlogst is the cache in case that file is busy / can't write the information
          'we can keep and write it later.
       
          If not mlogst is nothing then 

               'mean there is previous log that didn't write, so we write it.

               IO.File.AppendAllText(logfile,mlogst.tostring)

               'after write we empty it.

               mlogst = nothing

          End if

          'write the log information.. 

          IO.File.AppendAllText(logfile,mlog)

     Catch ex as exception

          'if there is error while write the log this time 
          ', we keep in the mlogst for write next time.

          If mlogst is nothing then mlogst = new system.text.stringbuilder

          mlogst.apppend(mlog)

     End try

End sub


//// to use…


Sub main


     Writelog ("starting program…")

     Do …..

     Writelog ("doing stuff…"

     Do …

     Writelog ("ending program..")

End sub


You can write more useful information , like the datetime of the log occur , current user that use this log..


IO.File.AppendAllText(logfile,mlog)


So you write as..


Io.file.appendalltext(logfile,string.concat(now , " " ,mlog))


You should have the log like this..


07-03-2011 6:35:01 PM starting program..
07-03-2011 6:35:02 PM doing stuff..
….
07-03-2011 6:36:01 PM ending program..

Sunday, March 6, 2011

How to check your hosting php version


How to check your hosting php version


Very easy way to check your information of php on your host, you just create file new .php

Then write this in your new page.









Then upload to your server.


You will receive all information about your php version , driver on your server.



Saturday, March 5, 2011

Best way to use string in vb.net programming


Best way to use string in vb.net programming


This is the very useful object that you can manage your string, especially when you want to concatenate your string in the loop.


Old:

Dim I as integer

Dim s as string

For I = 1 to 10000

S = s & "concat string"

next


new:
dim I as integer

dim s as new system.text.stringbuilder.

for I = 1 to 10000

s.append("concat string")

next


You will see a lot different when you have very long loop.

See more information here.

Thursday, March 3, 2011

the function equivalent to "doevent" in vb 6

The function equivalent to "doevent" in vb 6


In vb6 programming"doevent" is function that useful when you want to update your text on your form while you are using loop. unfortunately that this function is not exist in vb.net. but we can use this code below to have similar result.


    Private Delegate Sub EmptyDelegate()

    Public Sub DoEvents()
                    System.Windows.Threading.Dispatcher.CurrentDispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, New EmptyDelegate(AddressOf mfunction))
    End Sub

    Private Sub mfunction()
           'just leave it empty...
    End Sub

sample to use :
you want to update your text during the loop

dim i as integer
for i = 1 to 1000
     label1.text = "this is label in loop ..." & i
     DoEvents()
next

How to create your blog for free !

How to create your blog for free


Sep by step
1. goto http://www.blogspot.com/

blog_spot_screen














2. if you have Google account then you "sign in", if not you can create the Google account for free.
3. after sign in you will see step 1, you just fill your name then go next step.
blog_spot_step_1

















4. you will come to main page., at this place you can manage your blog easier., if you don't have yet 1 , click on button "create your blog now"
blog_spot_home















5. at here you put the "title" of your blog, and the put the name of your blog, you should select a good name that has some meaning to what you will write in your blog. , when you selected click on "Check Availability" to be sure that name is not in-use.
blog_spot_step_2


















6. now you have your own blog and ready for design.
blog_spot_page_design