Tampilkan postingan dengan label visual. Tampilkan semua postingan
Tampilkan postingan dengan label visual. Tampilkan semua postingan

Sample Code on How to Fill the Datagrid View in Visual Basic Net

Minggu, 16 Februari 2014

0 komentar
Sample on how to Fill the Datagrid View in Visual Basic .Net

Heres the code below.

Dim query as string="Select * from EmployeeTable"
Dim da as new oledbdataadapter(query,con)

dim ds as new dataset

da.fill(ds,"EmployeeTable")

me.dgv.datasource=ds
me.dgv.datamember="EmployeeTable"

ds.dispose

con.close
Read More..

Example ProgressBar in Visual Basic

Sabtu, 08 Februari 2014

0 komentar

Example ProgressBar in Visual Basic


Uses the ProgressBar to animate your program with actions such as stop, pause and resume his work are essential steps to good ProgressBar. Bad use of a ProgressBar can slow your program or make your program inaccessible.
I introduce two examples of ProgressBar in this article. The first one is a very simple case perfect for programmers who enjoy working in sequential programming as opposed to event-driven programming.


ProgressBar without Thread






<summary>
this is a sample on how to use a progress bar.
The main problem in this exemple is that the form is frooze while the progress bar is working.
</summary>
<remarks></remarks>
Public Class Form1

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

        Me.Text = My.Application.Info.AssemblyName


        With ProgressBar1
            .Style = ProgressBarStyle.Blocks
            .Step = 1
            .Minimum = 0
            .Maximum = 100
            .Value = 0
        End With

        With Button1
            .Text = "Start ProgressBar"
        End With

    End Sub

    Private Sub Button1_MouseUp(sender As System.Object, e As System.EventArgs) Handles Button1.MouseUp
        With ProgressBar1
            .Style = ProgressBarStyle.Blocks
            .Step = 1
            .Minimum = 0
            .Maximum = 100
            .Value = 0
        End With
        if you repress the button now, it wont restart now
        Do
            ALL events in your form will ahve to wait until this loop is completed!
            Threading.Thread.Sleep(100)
            ProgressBar1.PerformStep() cant use this if ProgressBar1.Style = ProgressBarStyle.Marquee

        Loop Until ProgressBar1.Value >= ProgressBar1.Maximum

        Me.Button1.Text = "finished, press to restart"

    End Sub
End Class




When you run the program and you press the button, the ProgressBar will animate. It works well because you could press the button a second time for the animation again. The value of the ProgressBar takes the value of zero and then increment at each stage of your programming work.

This example illustrates the perfect example of the most popular programming were computers were operating with a single processor 16-bit or Intel 80386, 80486, Pentium I, Pentium II, Citrix, AM386 or computer ... 32 bit until the 2000s. In fact, we were taught that the computer could only make a single statement at a time. And there was a time when the work of programmers was once measured by the number of lines of code written: 10000 lines, 50000 lines ...

What is interesting in this type of programming is that it is very popular not only in the programming software in computers but also in other applications such as electronic programming, industrial automation, engineering and more. For example, your dishwasher has a sequential behavior and has a sequence of wash cycles: closes the door, sprinkles, lather, rinse, dry and opens the door.


Programming events



In simple terms, the program must work in harmony with other competing programs and user. Program developed with events is the basic principle of the computer-aided design. This is obviously more difficult because the programmer first and foremost have a mentality contrary to selfishness. The programmer must think at all the elements around his program. For example, if the user wants to pause the program, nothing more frustrating than seeing the message "PROGRAM NOT RESPONDING" on the screen because the program is too busy to perform a certain task or because it was designed this way. Commercially speaking, then we can say that in 2013 the program was poorly designed.

Here is a code example of improved ProgressBar. In principle, it is almost the same as the previous example except that it is capable of handling user events with and be compatible with the resources of the computer.


 ProgressBar with Thread



<summary>
This is a sample of threading.
this sample have a PLAY, PAUSE, RESUME and STOP or Restart
Carefull, you cant use the ThreadState to check your Thread Status because is not reliable.
That is why a created a member called suspended.
</summary>
<remarks></remarks>
Public Class Form1
    Private tProgessBar As Threading.Thread
    Delegate Function tProgressBar_at_Max() As Boolean
    Private suspended As Boolean

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If tProgessBar Is Nothing Then tProgessBar = New Threading.Thread(AddressOf ProgessBarFunction)

        If tProgessBar.IsAlive Then
            If suspended Then
                suspended = Not suspended
               tProgessBar.Resume()
                Button1.Text = "Playing, click to pause"
            Else
                suspended = Not suspended
                tProgessBar.Suspend()
                Button1.Text = "Paused, click to resume"
            End If

        Else
            With ProgressBar1
                .Style = ProgressBarStyle.Blocks
                .Step = 1
                .Minimum = 0
                .Maximum = 100
                .Value = 0
            End With
            Button1.Text = "Playing, click to pause"
            tProgessBar = New Threading.Thread(AddressOf ProgessBarFunction)
            tProgessBar.IsBackground = True
            tProgessBar.Start()

            suspended = False
        End If
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Button1.Text = "Press to Start"
    End Sub

    Private Sub ProgessBarFunction()
        Do
            Me.Invoke(New MethodInvoker(Sub() Me.ProgressBar1.PerformStep()))

            Threading.Thread.Sleep(100)
        Loop Until ProgressBar_at_Max()
        Me.Invoke(New MethodInvoker(Sub() Me.Button1.Text = "finished, press to restart"))
    End Sub

    Private Function ProgressBar_at_Max() As Boolean
        ProgressBar_at_Max = False
        If ProgressBar1.Value >= ProgressBar1.Maximum Then
            ProgressBar_at_Max = True
        Else
            ProgressBar_at_Max = False
        End If

    End Function

End Class





First, the presence of a thread is important for the proper functioning of the programming events because you want to introduce a kind of subroutine in the main program which is our form. When you start the ProgressBar, the thread is constantly working, but in the background and becomes less important compared to Form1 and controls. We must also avoid falling into the room of the comparison. Many will think that a thread in the background is equivalent to the use of events as called Reactors or Events. Know that it is not at all the same thing. The mere fact that the level of experience required for the use of threads versus Reactors or Events should be enough to convince you.

 Note the use of the Resume function and suspends them which mean that the thread is suspended. During the time that the thread is suspended, the progress bar is virtually not using any resources from the processor.

You can download the program and source code examples used in this article.
Download a basic sample for the ProgressBar: progressBarSample.zip

Download more complex and interesting example of a ProgressBar: SampleProgressBarPause.zip





Read More..

Visual Studio Express 2012 for Desktop

Selasa, 04 Februari 2014

0 komentar

Visual Studio Express 2012 for Desktop


Microsoft decided to make programming more accessible than ever. With the new Visual Studio Express 2012 software, it will replace all previous express editions (Visual Basic, C#, C++. You could code with your favorite language and finally start learning a new one.

This software version is more complete with Windows Forms and win32 capabilities. What is best is that you could start developing Windows 8 applications and take advantage of and IntelliSense more powerful.

What is most interesting is the Team Foundation Server. With this tool, you could finally work as a professional with free software. The Team Foundation Server is in other word a Microsoft Life Cycle project management. With a tools a like this, you could easily save your project and sub-project. You could easily undo the mistake even if you saved your files. Work in team or share your code between specific individual will be easily a simple. Control and versioning is key for fast and efficient programming. That is quality.

Minimum requirement

Base with the information from Microsoft, the minimum requirement are:

Supported operating systems


  • Windows 7 SP1 (x86 and x64)
  • Windows 8 (x86 and x64)
  • Windows Server 2008 R2 SP1 (x64)
  • Windows Server 2012 (x64)


Supported architectures

  • 32-bit (x86)
  • 64-bit (x64)


Hardware requirements

  • 1.6 GHz or faster processor
  • 1 GB of RAM (1.5 GB if running on a virtual machine)
  • 5 GB of available hard disk space
  • 100 MB of available hard disk space (language pack)
  • 5400 RPM hard disk drive
  • DirectX 9-capable video card running at 1024 x 768 or higher display resolution



I decided to download and test Visual Studio Express 2012 for Desktop on my old Windows Vista and evaluate it. I could say I am pretty excited because it is close the Visual Studio 2010 Professional.

Here are the specifications of my old computer:

Test Computer specifications

  • Acer Aspire T180
  • AMD Athlon 64 3800+ (1 core processor)
  • 4 Go of RAM (Max Available is 3 Go)
  • 26 Go free space on my hard drive.
  • Windows Vista 32 bits Home Edition Service Pack 2
  • ATI Radeon HD 2400 Pro

Is important to keep in mind that the Express Edition is for personal use and it can’t be use for commercial use.

In other words, you could develop anything from the Express Editions event if you work for a company but you or your company can’t sell it or try to make profit with it.

Beside, if you want to sell or make money fro your code, you should always make the best of your with the best tools available.

You can’t permit your program to stop working if you client start using newer technologies, mobile, pad, laptop, desktop with Windows 7 or Windows 8 for desktop or for mobile.






Here is the link :

But if you are looking for something more complete, don’t hesitate and get the 2012 editions. It is an investment and a useful tool.


Buy Visual Studio Professional with MSDN 2012 from Amazon, cheapest you could find.




Read More..

Copyright © 2010-2022 Kabar Blog | Powered By Blogger