Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

VB.NET Programming Corner!

ericgmejia

The Immortal Symbianizer
Advanced Member
Messages
4,715
Reaction score
2
Points
28
I made this thread for all programmers starting their adventure in VB.NET.

Please post relevant and sensible questions regarding VB.NET,
share your knowledge and expertise, share codes and techniques.

Post question on HOW TOs:
How to do this or that, ill supply bits of code to accomplish basic tasks.

Ill be posting series of samples leading to complete applications,
your suggestions are encouraged.
These samples will contain codes relevant to other tasks as well.

Platform = VS2003 to VS2012

i suggest learn and get the feel of VB.NET/VISUAL STUDIO IDE first before posting questions,
so that we can talk on the same page.


Topics:
VB.NET Winforms (not Web Applications)
ADO.NET as applied in VB.NET
Crystal Reports on VB.NET
SQLServer as used in VB.NET
MSAccess as used in VB.NET
Classes
UserControls

Technologies:
Serial - like using SMS, Barcode and other hardware
TCP/IP - chat applications, sockets, internet applications
MSMQ - message queuing
Remoting - executing assemblies in other computer
WebServices - using webservices in windows forms
Multithreading - executing more than 1 process at the same time


Suggested Third Party Tools:
DevXPress 2009 Free Edition
SQLServer 2005 Express Edition

Suggested references:
http://www.homeandlearn.co.uk/net/vbnet.html
http://www.java2s.com/Tutorial/VB/CatalogVB.htm

I currently use Visual Studio 2008 only, but basic codes will apply to all versions

Please do not ask for a complete system,
instead use the codes and assistance that you will find here
to build your own system.


***Thanks to moderators, STICKY na ang thread!

Lets share knowledge so that we can be a more flexible and well rounded programmer. Be it for school or work.

Links:

First Post: Populating DataGridView using MSAccess Database
Second Post : Basic VB.NET MSAccess Tutorial
SQLServer Sample
 
Last edited:
First Post:

Populating DataGridView using MSAccess Database

attachment.php


Shown in 3ways
-using Dataset
-using DataReader
-binding the DataGridView to a dataset

attachment.php


Important points to learn:
OleDBConnection
OleDBCommand
OleDBAdapter
Dataset
DataReader
DataTable
Using My.Settings to save the database path

Program will search for the database if not found;
Sample code has comments as to how it is done
Post further questions if necessary:

Basic Steps:

Create a project:
Add a form:
Add this to the forms top most code
"Imports System.Data.OleDb"
Add the DataGridView
For non databound grid,
add the necessary columns using the datagridview designer (when selected; click the [>] button on the top rigth of the grid)
Follow the code provided


the file
ericVBNETAccess.rar
contains the design for the application series i wanted to construct for this thread
you will notice, walang pop windows, nasa tab page lang ang forms.
stay tuned to know how it is done.

UPDATED! - loading data into listview.

Updated SQL Server Sample
http://www.symbianize.com/attachment.php?attachmentid=369167&stc=1&d=1310119089

check also thee links
http://www.symbianize.com/showpost.php?p=8292447&postcount=2560
http://www.symbianize.com/showpost.php?p=8292571&postcount=2561
http://www.symbianize.com/showpost.php?p=8292709&postcount=2562

another sample of using usercontrol
http://www.symbianize.com/attachment.php?attachmentid=846939&d=1385380661
 

Attachments

  • Capture2.PNG
    Capture2.PNG
    53.2 KB · Views: 83,530
  • ericVBNETAccess.rar
    48.2 KB · Views: 4,072
  • ericVBNETAccessBasicOLEDB.rar
    896 KB · Views: 7,901
  • AppSample.rar
    144.3 KB · Views: 12,998
  • AppSample1a.rar
    148.2 KB · Views: 3,316
  • MicroPOS-Access.rar
    4.4 MB · Views: 8,534
  • LeShop.rar
    3.1 MB · Views: 7,465
Last edited:
sir, thanks po sa thread na eto..eto hanap ko.. eto kasi programming namin ngayun..and i know nothing about it kasi java at c yung ginamit namin noon..
may i ask a noob question..
ano po ang kaibahan ng visual studio at visual basic??..
 
sir, thanks po sa thread na eto..eto hanap ko.. eto kasi programming namin ngayun..and i know nothing about it kasi java at c yung ginamit namin noon..
may i ask a noob question..
ano po ang kaibahan ng visual studio at visual basic??..

malabo ang tanong mo,
i think ang ibig mo sabihin ay vb.net at vb6

Visual Studio is the IDE
like MSOFFICE na meron MSWORD at EXCEL

VB.NET is the language

http://en.wikipedia.org/wiki/Microsoft_Visual_Studio

eto yung versions



WIN32
Visual Studio 97 (VB5, C++, etc)
Visual Studio 6.0 (1998) (VB6, C++, VFP)
NOT SUPPORTED BY Microsoft anymore




Visual_studio_logo.png


.NET FRAMEWORK
Visual Studio .NET (2002) (VB.NET 2002, C#, etc)
Visual Studio .NET 2003 (VB.NET 2003, C#, etc)
Visual Studio 2005 (VB 2005, C#, etc)
Visual Studio 2008 (VB 2008, C#, etc)
Visual Studio 2010 (VB 2010, C#, etc)


VB6 is a WIN32 development tool
meaning ginagamit to create applications in the Windows32bit platform using native windows library.

VB.NET (VB2005 - VB2010) is a development tool to create applications running under the .NET Framework


sana malinaw yan so that we know na IISA lang ang tinutukoy nating bagay.
 
Last edited:
wow!..thanks for the info sir!..sana marami akong matutunan sa thread mong ito..newbie pa kasi ako eh..
salamat din sa paglagay ng link para dun sa mga terms..
thanks!..
tambay ako d2 ts kung pwd!..
:clap:
 
I want to learn more bout vbs...as a newbie what should i do?

sa otor, thanks for making this thread......
 
I want to learn more bout vbs...as a newbie what should i do?

sa otor, thanks for making this thread......

Download mo maski yung Express Edition and start using it,
type the codes you see here,
do not just copy,
understand what you are typing
and why you are typing it.

Refer to Google or MSDN for any keywords that you dont know.

See it run, admire your work.

You have all the resources at your disposal to learn this.
 
Yun! na-decide na pala na ihiwalay ang VB.net sa VB Thread

ok nga po kasi mahirap rin kasi lalo na dun sa nag uumpisa palang baka akalain nila ung discussion na iba dun sa vb thread is vb lang talaga..

:thanks:
 
TS pa tambay po dito. Nagtuturo po me ng Visual Basic sa school kaso ung VB 6.0 ang alam ko eh sbi sakin ng boss ko ung VB 2008 edition na ang ituro ko kaya medyo nangangapa pako iba kasi ung coding nya hehehe.
Thanks for creating this threads MABUHAY KA!!! :salute:
 
TS pa tambay po dito. Nagtuturo po me ng Visual Basic sa school kaso ung VB 6.0 ang alam ko eh sbi sakin ng boss ko ung VB 2008 edition na ang ituro ko kaya medyo nangangapa pako iba kasi ung coding nya hehehe.
Thanks for creating this threads MABUHAY KA!!! :salute:

try mo yung mga links na nasa first post, basic yung mga yun.
pwede natin pagtulungan kung anon topic ang ituturo mo at kung ano ang laman,
para naman di mahuli yung mga students mo
madami ako pde i share ng coding techniques para sa kanila
 
Last edited:
First Post:

Populating DataGridView using MSAccess Database

attachment.php


Shown in 3ways
-using Dataset
-using DataReader
-binding the DataGridView to a dataset

attachment.php


Important points to learn:
OleDBConnection
OleDBCommand
OleDBAdapter
Dataset
DataReader
DataTable
Using My.Settings to save the database path

Program will search for the database if not found;
Sample code has comments as to how it is done
Post further questions if necessary:

Basic Steps:

Create a project:
Add a form:
Add this to the forms top most code
"Imports System.Data.OleDb"
Add the DataGridView
For non databound grid,
add the necessary columns using the datagridview designer (when selected; click the [>] button on the top rigth of the grid)
Follow the code provided


the file
ericVBNETAccess.rar
contains the design for the application series i wanted to construct for this thread
you will notice, walang pop windows, nasa tab page lang ang forms.
stay tuned to know how it is done.

medyo mahaba po yung code 'nyo, ewan ko kung best ba ito. Meron po akong ibang way.. Sunday kasi ngayon, nasa net cafe lang ako.. bukas, i.upload ko dito yung code ko in populating datagrid as ms access as backend! Wala kasi Visual Studio dito..
 
medyo mahaba po yung code 'nyo, ewan ko kung best ba ito. Meron po akong ibang way.. Sunday kasi ngayon, nasa net cafe lang ako.. bukas, i.upload ko dito yung code ko in populating datagrid as ms access as backend! Wala kasi Visual Studio dito..

as i said i presented 3 ways to do it, look at method3.

malamang naka bound ka sa isang design time datasource. i dont do that,
wala masyado control sa runtime pag ganun.
madami ka di pde gawin pag naka bound na yung grid.
which you will see as the samples progress.

what im showing here is also applicable to other controls not just datagridview.
and i want to show rin how it is done in code

the code is not only for datagridview, you can use the code in other operations as well.

if you have a better code to share then tignan natin, you can open your file naman sa notepad muna so we can see it.
baka di ko pa alam yang method mo.
share tayo ng mag codes and techniques. this is what this forum is for.
 
Last edited:
Question po, I made a class for reading and sending text messages and in that class I have a windows.forms.timer it is working perfectly fine so i tried to compile it as a class library and changed the windows.forms.timer to system.timers.timer when i tried to use it on the same program it has an error "Stack Overflow".

for people who don't know the difference between windows.forms.timer and system.timers.timer is windows.forms.timer can only be used on windows forms. surprised? hehehe

is there a difference on their behavior?
 
Question po, I made a class for reading and sending text messages and in that class I have a windows.forms.timer it is working perfectly fine so i tried to compile it as a class library and changed the windows.forms.timer to system.timers.timer when i tried to use it on the same program it has an error "Stack Overflow".

for people who don't know the difference between windows.forms.timer and system.timers.timer is windows.forms.timer can only be used on windows forms. surprised? hehehe

is there a difference on their behavior?

dapat hindi windows.Forms.Timer ang ginamit mo

try mo to
Code:
Public Class TimerClas
    Dim cTime As New Timer

    Friend Sub New(ByVal Interval As Long)
        cTime.Interval = Interval
        [COLOR="Red"]AddHandler cTime.Tick, AddressOf TimerEvent[/COLOR]
    End Sub

    Friend Sub TimerStart()
        cTime.Start()
    End Sub

    Friend Sub TimerStop()
        cTime.Stop()
    End Sub

    Friend ReadOnly Property TimeElapsed() As Integer
        Get
            Dim nElapsed As Integer
            Return nElapsed
        End Get
    End Property

    Private Sub TimerEvent()
        'dito mag TICK ang timer

    End Sub
End Class
 
dapat hindi windows.Forms.Timer ang ginamit mo

try mo to
Code:
Public Class TimerClas
    Dim cTime As New Timer

    Friend Sub New(ByVal Interval As Long)
        cTime.Interval = Interval
        [COLOR="Red"]AddHandler cTime.Tick, AddressOf TimerEvent[/COLOR]
    End Sub

    Friend Sub TimerStart()
        cTime.Start()
    End Sub

    Friend Sub TimerStop()
        cTime.Stop()
    End Sub

    Friend ReadOnly Property TimeElapsed() As Integer
        Get
            Dim nElapsed As Integer
            Return nElapsed
        End Get
    End Property

    Private Sub TimerEvent()
        'dito mag TICK ang timer

    End Sub
End Class

ito po code ko
Code:
public ctimer as system.timers.timer
sub new()

AddHandler ctimer.Elapsed, AddressOf DOSOMETHING()
ctimer.interval = 1000
ctimer.start
end sub

private sub DOSOMETHING
 'something
end sub


san po kinuha ung timer nyo? ang alam ko lang po kasi

windows.forms.timer
system.timers.timer
threading.timer
 
Last edited:
ito po code ko
Code:
public ctimer as system.timers.timer
sub new()

AddHandler ctimer.Elapsed, AddressOf DOSOMETHING()
ctimer.interval = 1000
ctimer.start
end sub

private sub DOSOMETHING
 'something
end sub


san po kinuha ung timer nyo? ang alam ko lang po kasi

windows.forms.timer
system.timers.timer
threading.timer


Forms.Timer yan, gumagamit ng Tick e

eto try mo mas ok

Code:
Imports System
Imports System.Timers

Public Class Timer1

    Private xTimer As System.Timers.Timer

    Public Shared Sub Main()
        ' Create a timer with a ten second interval.
        xTimer = New System.Timers.Timer(10000)

        ' Hook up the Elapsed event for the timer.
        AddHandler xTimer.Elapsed, AddressOf OnTimerEvent

        ' Set the Interval to 2 seconds (2000 milliseconds).
        xTimer.Interval = 2000
        xTimer.Enabled = True

        Console.WriteLine("Press the Enter key to exit the program.")
        Console.ReadLine()
xTimer.AutoReset
   End Sub

    ' Specify what you want to happen when the Elapsed event is 
    ' raised.
    Private Shared Sub OnTimerEvent(source As Object, e As ElapsedEventArgs)
        Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime)
    End Sub
End Class

'Output:
'
'Press the Enter key to exit the program.
'The Elapsed event was raised at 5/20/1900 8:42:27 PM
'The Elapsed event was raised at 5/20/1900 8:42:29 PM
'The Elapsed event was raised at 5/20/1900 8:42:31 PM
'...
 
Last edited:
Forms.Timer yan, gumagamit ng Tick e

eto try mo mas ok

Code:
Imports System
Imports System.Timers

Public Class Timer1

    Private xTimer As System.Timers.Timer

    Public Shared Sub Main()
        ' Create a timer with a ten second interval.
        xTimer = New System.Timers.Timer(10000)

        ' Hook up the Elapsed event for the timer.
        AddHandler xTimer.Elapsed, AddressOf OnTimerEvent

        ' Set the Interval to 2 seconds (2000 milliseconds).
        xTimer.Interval = 2000
        xTimer.Enabled = True

        Console.WriteLine("Press the Enter key to exit the program.")
        Console.ReadLine()
xTimer.AutoReset
   End Sub

    ' Specify what you want to happen when the Elapsed event is 
    ' raised.
    Private Shared Sub OnTimerEvent(source As Object, e As ElapsedEventArgs)
        Console.WriteLine("The Elapsed event was raised at {0}", e.SignalTime)
    End Sub
End Class

'Output:
'
'Press the Enter key to exit the program.
'The Elapsed event was raised at 5/20/1900 8:42:27 PM
'The Elapsed event was raised at 5/20/1900 8:42:29 PM
'The Elapsed event was raised at 5/20/1900 8:42:31 PM
'...



i think na solve ko na po problem ko. sana you can support me sa observation ko. ganto po un

windows.forms.timers inaantay nya matapos ung buong procedure na nkalagay sa tick event nya before mag trigger ulit incase na hindi pa tapos ang event eh tapos na interval.

system.timers.timer trigger ng trigger ang events based on interval kahit na hindi pa tapos ang procedures.

tama po ba observation ko?
 
i think na solve ko na po problem ko. sana you can support me sa observation ko. ganto po un

windows.forms.timers inaantay nya matapos ung buong procedure na nkalagay sa tick event nya before mag trigger ulit incase na hindi pa tapos ang event eh tapos na interval.

system.timers.timer trigger ng trigger ang events based on interval kahit na hindi pa tapos ang procedures.

tama po ba observation ko?

tama, asynchronous ang timer, supposed to be
pero nasa same thread sila ng task mo,

The System.Windows.Forms.Timer runs on the same thread as the application.
So if your application is carrying out some processor-intensive task, the
timer ticks are not going to be fired since the thread is busy doing your
task. Instead, use the System.Timers.Timer (which runs on a seperate thread
than the application) and write your code in the Elapsed event of the timer.

pag System.Timers;
mag tick ulit yan basta inabutan ng interval, walang pakialam kung may ginagawa pa sa loob ng tick event.

kung gusto mo tapusin yung task, i stop/disable mo muna yung timer, then after ng task, saka ka mag start/enable ulit para synchronized
 
Last edited:
tama, asynchronous ang timer

mag tick ulit yan basta inabutan ng interval, walang pakialam kung may ginagawa pa sa loob ng tick event.

kung gusto mo tapusin yung task, i stop/disable mo muna yung timer, then after ng task, saka ka mag start/enable ulit

thanks po ok na prob ko.
 
Back
Top Bottom