If IsDBNull(DataGridView1.CurrentRow.Cells(0).Value) Then
txtKd_Aktiva.Text = ""
txtKd_Dept.Text = ""
Else
txtKd_Aktiva.Text = DataGridView1.CurrentRow.Cells(0).Value
txtKd_Dept.Text = DataGridView1.CurrentRow.Cells(1).Value
End If
Showing posts with label Visual Basic. Show all posts
Showing posts with label Visual Basic. Show all posts
Sunday, November 17, 2013
Wednesday, November 13, 2013
ToolStrip Collect Command
-- save
Private Sub SaveToolStripButton_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton.Click
Dim frm As Object = Me.ActiveMdiChild
If frm Is Nothing Then Return
Call frm.save()
End Sub
--delete
Private Sub DeleteToolStripButton_Click(sender As Object, e As EventArgs) Handles DeleteToolStripButton.Click
If MsgBox("Are you sure want to Delete?", MsgBoxStyle.YesNo, "Delete") = MsgBoxResult.Yes Then
Dim frm As Object = Me.ActiveMdiChild
If frm Is Nothing Then Return
Call frm.delete()
Else
MsgBox("You aren't deleted")
End If
End Sub
--filter
Private Sub FilterToolStripButton_Click(sender As Object, e As EventArgs) Handles FilterToolStripButton.Click
Dim frm As Object = Me.ActiveMdiChild
If frm Is Nothing Then Return
Call frm.Filter()
End Sub
Private Sub SaveToolStripButton_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton.Click
Dim frm As Object = Me.ActiveMdiChild
If frm Is Nothing Then Return
Call frm.save()
End Sub
--delete
Private Sub DeleteToolStripButton_Click(sender As Object, e As EventArgs) Handles DeleteToolStripButton.Click
If MsgBox("Are you sure want to Delete?", MsgBoxStyle.YesNo, "Delete") = MsgBoxResult.Yes Then
Dim frm As Object = Me.ActiveMdiChild
If frm Is Nothing Then Return
Call frm.delete()
Else
MsgBox("You aren't deleted")
End If
End Sub
--filter
Private Sub FilterToolStripButton_Click(sender As Object, e As EventArgs) Handles FilterToolStripButton.Click
Dim frm As Object = Me.ActiveMdiChild
If frm Is Nothing Then Return
Call frm.Filter()
End Sub
Sunday, October 27, 2013
Microsoft Report Viewer with MySQL - VB.net
You can see this tutorial at youtube :
Part 1 :
http://www.youtube.com/watch?v=tuwZNSwTjEI
Part 2 :
http://www.youtube.com/watch?v=-Ic64qxWf0k
Part 1 :
http://www.youtube.com/watch?v=tuwZNSwTjEI
Part 2 :
http://www.youtube.com/watch?v=-Ic64qxWf0k
Sunday, October 20, 2013
RDLC Reporting Example
If you want create RDLC Reporting example, you can see in youtube :
http://www.youtube.com/watch?v=NVImPdRbVAs
http://www.youtube.com/watch?v=NVImPdRbVAs
Tuesday, October 15, 2013
Rdlc
Rdlc, yes. This name for pure report from Visual Studio.
Report Designer (Visual Studio)
Report Designer (Visual Studio)
The Visual Studio Report Designer provides a user-friendly interface for creating robust reports that include data from multiple types of data sources.
In Visual Studio, reports are saved as client report definition (.rdlc) files. These files are based on the same schema as report definition (.rdl) files published on SQL Server Reporting Services report servers, but they are stored and processed differently than .rdl files. At run time, the .rdlc files are processed locally, and the .rdl files are processed remotely.
Source : http://msdn.microsoft.com/en-us/library/bb558708.aspx
Source : http://msdn.microsoft.com/en-us/library/bb558708.aspx
Monday, October 14, 2013
Insert, Update
Insert :
Insert myTable(myField1, myField2,myField3) values ('Value1','Value2','Value3')
Update :
Update myTable set myField = newValue where myKey = myKeyField
Insert myTable(myField1, myField2,myField3) values ('Value1','Value2','Value3')
Update :
Update myTable set myField = newValue where myKey = myKeyField
SaveToolStripButton
Save with SaveToolStripButton
Private Sub SaveToolStripButton_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton.Click
Dim frm As Object = Me.ActiveMdiChild
If frm Is Nothing Then Return
Call frm.save()
End Sub
In form mdiChild
Public Class frmChangePassword
Public Sub Save()
Dim Query As String
Dim sDB = New sqlDB
Query = "insert jnsbrg(kelomp_brg,nm_jns_brg) VALUES ('"
Query = Query + txtKelomp_Brg.Text + "','" + txtNm_Jns_Brg.Text + "')"
sDB.executeSQL(Query)
MDIParent1.SaveToolStripButton.Enabled = False
MDIParent1.NewToolStripButton.Enabled = True
End Sub
End Class
Private Sub SaveToolStripButton_Click(sender As Object, e As EventArgs) Handles SaveToolStripButton.Click
Dim frm As Object = Me.ActiveMdiChild
If frm Is Nothing Then Return
Call frm.save()
End Sub
In form mdiChild
Public Class frmChangePassword
Public Sub Save()
Dim Query As String
Dim sDB = New sqlDB
Query = "insert jnsbrg(kelomp_brg,nm_jns_brg) VALUES ('"
Query = Query + txtKelomp_Brg.Text + "','" + txtNm_Jns_Brg.Text + "')"
sDB.executeSQL(Query)
MDIParent1.SaveToolStripButton.Enabled = False
MDIParent1.NewToolStripButton.Enabled = True
End Sub
End Class
Standardized Naming Conventions for Visual Basic .NET
When you’re programming, names are important. If you’re programming with Visual Basic .NET, the following table can be a major help in getting the names right. It gives the common prefix to use when naming objects so you can quickly tell your check boxes from your combo boxes and your radio buttons from your record sets.
Prefix | Corresponding Object | Example | Prefix | Corresponding Object | Example |
---|---|---|---|---|---|
Acd | ActiveDoc | AcdMainPage | Hpl | HyperLink | HplURL |
Chk | CheckBox | ChkBoldface | Lbl | Label | LblContents |
Cbo | ComboBox | CboDropper | Lst | ListBox | LstNames |
Cm | ADO command (database) | CmMyCommand | Pag | Page | PagTurn |
Cmd | CommandButton | CmdExit | Pgf | PageFrame | PgfRule |
Cmg | CommandGroup | CmgSelectOne | Prj | ProjectHook | PrjSuzerine |
Cn | Connection (database) | CnMyConnex | Rb | RadioButton | RbBlueBackground |
Con | Container | CntFramed | Rs | Recordset (database) | RsTotalSales |
Ctr | Control | CtlSeeThis | Sep | Separator | SepZone |
Fld | Field (database) | FldTitles | Spn | Spinner | SpnWatch |
Frm | Form | FrmColors | Txt | TextBox | TxtAddress |
Frs | FormSet | FrsTypeIn | Tmr | Timer | TmrAnimation |
Grd | Grid | GrdGoods | Tbr | ToolBar | TbrDropThis |
Grc | Column (in grid) | GrcQuantity | Tbl | Table (database) | TblTitles |
Grh | Header (in grid) | GrhYearsResults |
Source : http://www.dummies.com/how-to/content/standardized-naming-conventions-for-visual-basic-n.html
Other link for naming conventions :
http://www.ssw.com.au/ssw/Standards/DeveloperdotNET/DotNetStandard_ObjectNaming.aspx
Other link for naming conventions :
http://www.ssw.com.au/ssw/Standards/DeveloperdotNET/DotNetStandard_ObjectNaming.aspx
Mod Operator
Divides two numbers and returns only the remainder.
If you familiar with foxpro, this operator same with %.
Dim testResult As Double testResult = 10 Mod 5 testResult = 10 Mod 3 testResult = 12 Mod 4.3 testResult = 12.6 Mod 5 testResult = 47.9 Mod 9.35The expressions in the previous example return values of 0, 1, 3.4, 2.6, and 1.15.
If you familiar with foxpro, this operator same with %.
Math.Round Method
Rounds a value to the nearest integer or to the specified number of fractional digits.
This member is overloaded. For complete information about this member, including syntax, usage, and examples, click a name in the overload list.
Overload List
Source : http://msdn.microsoft.com/en-us/library/system.math.round.aspx
Overload List
Name
|
Description
|
Rounds a decimal value to the nearest
integral value.
|
|
Rounds a double-precision floating-point
value to the nearest integral value.
|
|
Rounds a decimal value to a specified number
of fractional digits.
|
|
Rounds a decimal value to the nearest
integer. A parameter specifies how to round the value if it is midway between
two numbers.
|
|
Rounds a double-precision floating-point
value to a specified number of fractional digits.
|
|
Rounds a double-precision floating-point
value to the nearest integer. A parameter specifies how to round the value if
it is midway between two numbers.
|
|
Rounds a decimal value to a specified number
of fractional digits. A parameter specifies how to round the value if it is
midway between two numbers.
|
|
Rounds a double-precision floating-point
value to a specified number of fractional digits. A parameter specifies how
to round the value if it is midway between two numbers.
|
Source : http://msdn.microsoft.com/en-us/library/system.math.round.aspx
Sunday, October 13, 2013
Login
If you will create Login, you can use this script :
Imports MySql.Data.MySqlClient
Private Sub cmbOK_Click(sender As Object, e As EventArgs) Handles cmbOK.Click
Dim conn As MySqlConnection
'Connect to the database using these credentials
conn = New MySqlConnection
conn.ConnectionString = "Data Source=127.0.0.1;Database= namedatabase;User ID=name user;Password= password;"
'Try and connect (conn.open)
Try
conn.Open()
Catch myerror As MySqlException 'If it fails do this... (i.e. no internet or intranet connection, etc.)
MsgBox("Error connecting to database. Check your internet / intranet connection.", MsgBoxStyle.Critical)
End Try
'MySQL query (where to call for information)
Dim myAdapter As New MySqlDataAdapter
'Tell where to find the file with the emails/passes stored
Dim sqlquery = "SELECT * FROM userid WHERE UserID = '" & txtUserID.Text & "' AND Password = '" & txtPassword.Text & "'"
Dim myCommand As New MySqlCommand
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'Start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader
'See if the user exists
If myData.HasRows = 0 Then
MsgBox("Invalid user id or password.", MsgBoxStyle.Critical)
'Insert your settings change here. (i.e. My.Settings.LoggedIn = False)
Else
MsgBox("Logged in as " & txtUserID.Text & ".", MsgBoxStyle.Information)
'MDIParent1.gcUserID = txtUserID.Text
MDIParent1.ToolStripStatusLabel.Text = "Logged in as : " & txtUserID.Text
'Another settings change: My.Settings.LoggedIn = True
Me.Close() 'close the login form End Sub
End If
End Sub
Imports MySql.Data.MySqlClient
Private Sub cmbOK_Click(sender As Object, e As EventArgs) Handles cmbOK.Click
Dim conn As MySqlConnection
'Connect to the database using these credentials
conn = New MySqlConnection
conn.ConnectionString = "Data Source=127.0.0.1;Database= namedatabase;User ID=name user;Password= password;"
'Try and connect (conn.open)
Try
conn.Open()
Catch myerror As MySqlException 'If it fails do this... (i.e. no internet or intranet connection, etc.)
MsgBox("Error connecting to database. Check your internet / intranet connection.", MsgBoxStyle.Critical)
End Try
'MySQL query (where to call for information)
Dim myAdapter As New MySqlDataAdapter
'Tell where to find the file with the emails/passes stored
Dim sqlquery = "SELECT * FROM userid WHERE UserID = '" & txtUserID.Text & "' AND Password = '" & txtPassword.Text & "'"
Dim myCommand As New MySqlCommand
myCommand.Connection = conn
myCommand.CommandText = sqlquery
'Start query
myAdapter.SelectCommand = myCommand
Dim myData As MySqlDataReader
myData = myCommand.ExecuteReader
'See if the user exists
If myData.HasRows = 0 Then
MsgBox("Invalid user id or password.", MsgBoxStyle.Critical)
'Insert your settings change here. (i.e. My.Settings.LoggedIn = False)
Else
MsgBox("Logged in as " & txtUserID.Text & ".", MsgBoxStyle.Information)
'MDIParent1.gcUserID = txtUserID.Text
MDIParent1.ToolStripStatusLabel.Text = "Logged in as : " & txtUserID.Text
'Another settings change: My.Settings.LoggedIn = True
Me.Close() 'close the login form End Sub
End If
End Sub
Saturday, October 5, 2013
Hello World
Visual Studio Languages
Find the resources for learning and for using the Visual Studio languages, to build the applications you need.ramming models.
Visual C++
Get the resources to learn and use the powerful and flexible Visual C++ language, with the tools to enable the development of native Windows apps, native desktop apps, and managed apps that run on the .NET Framework.
Visual C#
Get an introduction to C#, an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the .NET Framework. Find the resources for learning Visual C#, and for building application.
Visual Basic
Discover a wealth of resources for learning and using Visual Basic, a language engineered for productively building type-safe and object-oriented applications, for both the beginner and the experienced developer.
JavaScript
Learn about how to use Microsoft's implementation of JavaScript, which is compliant with the ECMAScript Language Specification 5th Edition, for creating Windows Store and Windows Phone apps, and on the web.
Visual F#
Build your Visual F# development skills and learn about the F# language, a multi-paradigm programming language targeting the .NET platform. The F# language supports functional, object-oriented, and imperative programming models.
Visual C++
Get the resources to learn and use the powerful and flexible Visual C++ language, with the tools to enable the development of native Windows apps, native desktop apps, and managed apps that run on the .NET Framework.
Visual C#
Get an introduction to C#, an elegant and type-safe object-oriented language that enables developers to build a variety of secure and robust applications that run on the .NET Framework. Find the resources for learning Visual C#, and for building application.
Visual Basic
Discover a wealth of resources for learning and using Visual Basic, a language engineered for productively building type-safe and object-oriented applications, for both the beginner and the experienced developer.
JavaScript
Learn about how to use Microsoft's implementation of JavaScript, which is compliant with the ECMAScript Language Specification 5th Edition, for creating Windows Store and Windows Phone apps, and on the web.
Visual F#
Build your Visual F# development skills and learn about the F# language, a multi-paradigm programming language targeting the .NET platform. The F# language supports functional, object-oriented, and imperative programming models.
Simple call form from MDIParent
If you want call form from MDIParent, this script is manner for this case :
Form menu in MDIParent, click this menu, then it's show procedure click as like below.
Private Sub StockToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles StockToolStripMenuItem.Click
frmStock.MdiParent = Me
frmStock.Show()
End Sub
Form menu in MDIParent, click this menu, then it's show procedure click as like below.
Private Sub StockToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles StockToolStripMenuItem.Click
frmStock.MdiParent = Me
frmStock.Show()
End Sub
Subscribe to:
Posts (Atom)