|
|
Hello, Guest! Welcome to Symbianize forums.
Most of our features and services are available only to our members. So we encourage you to login or join us by registering a new account. Registration is free, fast, and simple. You only need to provide a valid email address so we can minimize spammers. As a Symbianize member you'll have the following privileges:
- Gain access to private forums and restricted features
- Reply and create new topics or polls
- Download free applications, games, themes, graphics, tones, videos, etc.
- Ask question or support related to mobile phone, computer, game console, and multimedia
- Private messaging (PM) with fellow members
- Communicate instantly or real-time with currently online members via Shout Box
All that and more, so what are you waiting for, join us now! Ito ang website na ginawa ng pinoy para sa pinoy!
| |
| Programming Discussions related to C++, HTML, PHP, ASP, ColdFusion, JavaScript, Perl, Phyton, Ruby, WML, SQL, XML, and other programming languages. |
 |
|

20th Jun 2010 Sun, 14:23
|
 |
Forum Advisor
|
|
Join Date: Mar 2009
Location: Shadow Island
Posts: 535
Reputation:
|
|
Re: VB.NET Programming Corner!
Quote:
Originally Posted by ericgmejia
First Post:
Populating DataGridView using MSAccess Database
Shown in 3ways
-using Dataset
-using DataReader
-binding the DataGridView to a dataset
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..
|

20th Jun 2010 Sun, 14:34
|
 |
The Legend
|
|
Join Date: Dec 2007
Location: Makati City
Posts: 6,567
Reputation:
|
|
Re: VB.NET Programming Corner!
Quote:
Originally Posted by ako2
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 by ericgmejia; 20th Jun 2010 Sun at 15:10..
|

21st Jun 2010 Mon, 12:59
|
 |
The Grand Master
|
|
Join Date: Jan 2010
Location: local disk (c:)
Posts: 4,035
Reputation: 
|
|
Re: VB.NET Programming Corner!
thanks po master..
|

21st Jun 2010 Mon, 13:18
|
 |
Forum Advisor
|
|
Join Date: Mar 2010
Location: earth
Posts: 909
Reputation:
|
|
Re: VB.NET Programming Corner!
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?
|

21st Jun 2010 Mon, 14:06
|
 |
The Legend
|
|
Join Date: Dec 2007
Location: Makati City
Posts: 6,567
Reputation:
|
|
Re: VB.NET Programming Corner!
Quote:
Originally Posted by doorbreaker
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
AddHandler cTime.Tick, AddressOf TimerEvent
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
|

21st Jun 2010 Mon, 14:18
|
 |
Forum Advisor
|
|
Join Date: Mar 2010
Location: earth
Posts: 909
Reputation:
|
|
Re: VB.NET Programming Corner!
Quote:
Originally Posted by ericgmejia
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
AddHandler cTime.Tick, AddressOf TimerEvent
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 by doorbreaker; 21st Jun 2010 Mon at 14:19..
|

21st Jun 2010 Mon, 14:39
|
 |
The Legend
|
|
Join Date: Dec 2007
Location: Makati City
Posts: 6,567
Reputation:
|
|
Re: VB.NET Programming Corner!
Quote:
Originally Posted by doorbreaker
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 by ericgmejia; 21st Jun 2010 Mon at 14:48..
|

21st Jun 2010 Mon, 15:48
|
 |
Forum Advisor
|
|
Join Date: Mar 2010
Location: earth
Posts: 909
Reputation:
|
|
Re: VB.NET Programming Corner!
Quote:
Originally Posted by ericgmejia
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?
|

21st Jun 2010 Mon, 16:01
|
 |
The Legend
|
|
Join Date: Dec 2007
Location: Makati City
Posts: 6,567
Reputation:
|
|
Re: VB.NET Programming Corner!
Quote:
Originally Posted by doorbreaker
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,
Quote:
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 by ericgmejia; 21st Jun 2010 Mon at 16:27..
|

21st Jun 2010 Mon, 16:13
|
 |
Forum Advisor
|
|
Join Date: Mar 2010
Location: earth
Posts: 909
Reputation:
|
|
Re: VB.NET Programming Corner!
Quote:
Originally Posted by ericgmejia
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.
|
 |
|
All times are GMT +8. The time now is 15:42.
|