Deep interoperability with business and consumer platforms lets you build what your users want, where they want it
Create apps in a streamlined UI where common tasks are presented in a fresh, integrated development experience
Consolidate many development tasks into one tool so you can enhance existing apps or build new modern ones
Requirements: Processor - 1.6GHz+ CPUOS - Windows 8 (x86/x64), Windows 7 SP1 (x86/x64), Windows Server 2008 R2 SP1 (x64), Windows Server 2012 (x64)Memory(RAM) - 1GB (1.5GB if running on a virtual machine.
Why buy Visual Studio Professional with MSDN?
Software development doesn’t stand still—you push the technology envelope one day, and then need yesterday’s platforms and tools to support legacy apps the next. Visual Studio Professional with MSDN gives you access to Microsoft platforms and tools from the past and present, with new releases being added all the time. Plus, since it includes Team Foundation Server, you get the tools you need to work well with others. And now you have services to take your apps to the cloud, Windows Store, and Windows Phone Marketplace. Get Visual Studio Professional with MSDN and raise your development game.
4. Sample code to add item to listview (When click button add item to listview) Dim pObj As New ListViewItem("Code") pObj.SubItems.Add("Item Name") pObj.SubItems.Add("10.00") pObj.SubItems.Add("1") pObj.SubItems.Add("1.50")) pObj.SubItems.Add("15.00") pObj.Tag = 1 ' keep materail id ListView1.Items.Add(pObj)
5. Sample code to delete item in listview when press delete on keyboard. Private Sub ListView1_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles lstMaterial.KeyUp If e.KeyCode = Keys.Delete AndAlso ListView1.SelectedItems.Count > 0 Then For i As Integer = ListView1.SelectedItems.Count - 1 To 0 Step -1 ListView1.Items.RemoveAt(ListView1.SelectedItems(i).Index) Next End If End Sub
Dim client AsNew SmtpClient() Dim sendTo AsNew MailAddress("sendToAccount@gmail.com") Dim from As MailAddress = New MailAddress("from@address.com") Dim message AsNew MailMessage(from,sendTo) message.IsBodyHtml = True message.Subject = "Test SMTP" message.Body = "Got it!!"
' Use the same account in app.config to authenticate. Dim basicAuthenticationInfo AsNew System.Net.NetworkCredential("yourAccount@xxx.com", "YourPassword")
Product Description Professional Visual Basic 2008
The 2008 version of Visual Basic is tremendously enhanced and introduces dramatic new concepts, techniques, and features to this popular object-oriented language. Written by an elite author team who are sympathetic to the challenges of learning VB 2008, this comprehensive book provides a clear and concise approach to using VB 2008 in the ever-expanding .NET world.
This book focuses on using the latest and most powerful tools from the Microsoft arsenal within your Visual Basic solutions. Looking closely at LINQ, AJAX, a new Visual Studio and more, you'll be able to take lessons from this book and apply them to what you are doing today. You'll examine everything from the .NET Framework to the best practices for deploying .NET applications to database access and integrating with other technologies, such as COM and XML.
What you will learn from this book
* The core elements of VB 2008 as well as full syntax of all the new additions the language offers * Ways that the Common Language Runtime (CLR) is responsible for managing the execution of code compiled on the .NET platform * How VB is used in the creation, installation, running, and debugging of Windows? Services * How to work with the new SQL Server 2008 along with your .NET applications * The many features of Windows Forms and Windows Presentation Foundation * Ways to take advantage of the abilities of LINQ * The new web technology introduced by Silverlight
Who this book is for
This book is for experienced developers who are looking to transition to the latest version of Visual Basic.
Wrox Professional guides are planned and written by working programmers to meet the real-world needs of programmers, developers, and IT professionals. Focused and relevant, they address the issues technology professionals face every day. They provide examples, practical solutions, and expert education in new technologies, all designed to help programmers do a better job.
Microsoft Visual Basic .NET Programmer's Cookbook (Pro-Developer)
Finally, a book with one-stop shopping for VB.NET! I’ve read several cookbook-style programming titles in the past, and I was pleasantly surprised to find this has much more depth than I expected. It can’t cover everything (.NET is huge), but every time I pick the book up I learn something new. There are so many highlights–just browse through the table of contents and you’ll see what I mean! Here are some of my favorites: * Send keystrokes to another app * Create a thread-safe control wrapper * Great data-binding tips (image-to-picture box, etc.) * Factory, Registry, Singleton, Memento, and Lazy Initialization patterns * POP3, FTP, and Ping classes in the networking section * How to change a password into a salted hash for storage in a database * Use ZIP and PDF files (disclaimer: some third-party code is required, although it’s free) * Manage print jobs that are underway * Get Windows accounts and roles * Do hit testing with custom graphics * Defend against SQL injection * Dynamically generate an ASP.NET graphic * Add ASP.NET controls on the fly * MAPI and MCI (unfortunately, just through the ActiveX controls) * Upload binary data with a web service * Use a web service in VB 6
Inside Microsoft SQL Server 2008: T-SQL Programming (Pro-Develper)
Product Description Tackle the toughest set-based querying and query tuning problems—guided by an author team with in-depth, inside knowledge of T-SQL. Deepen your understanding of architecture and internals—and gain practical approaches and advanced techniques to optimize your code’s performance. Discover how to: * Move from procedural programming to the language of sets and logic * Optimize query tuning with a top-down methodology * Assess algorithmic complexity to predict performance * Compare data-aggregation techniques, including new grouping sets * Manage data modification—insert, delete, update, merge—for performance * Write more efficient queries against partitioned tables * Work with graphs, trees, hierarchies, and recursive queries * Plus—Use pure-logic puzzles to sharpen your problem-solving skills
How to show and hide your form in windows system tray.
1. Add NotifyIcon class in your project (System.Windows.Forms.NotifyIcon) and drag it into form.
2. Change NotifyIcon properties.
BalloonTipIcon = Info BalloonTipText = Running Change Icon Text = Running Your Program Visible = True
3. Add code in Event Form1_Resize.
Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles MyBase.Resize ' If minimize form that will show in system tray. If System.Windows.Forms.FormWindowState.Minimized = WindowState Then sysMonTray.ShowBalloonTip(5, "Running", "Running Your Program", ToolTipIcon.Info) Me.Hide() End If End Sub
4. Add code in Event NotifyIcon_Click to hide and show form.
Private Sub sysMonTray_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _ Handles sysMonTray.Click If Me.Visible Then Me.Hide() Else Me.Show() Me.ShowInTaskbar = True Me.WindowState = FormWindowState.Normal Me.StartPosition = FormStartPosition.CenterScreen End If
The two best methods for automatically launching a program at startup are to use the registry or the system's Startup folder. Which method you choose depends on how easy you want to make it for the user to remove the program if he or she decides that it shouldn't run at system startup. Using the Startup folder gives the user more control; to prevent the program from running at startup, the user just has to remove its shortcut from the folder. Using the registry makes it less accessible; the user will have to be familiar with the structure of the registry and will have to know how to use an editing tool like RegEdit in order to prevent the application from running at startup. Sample Code.
'Write to register Dim regKey As Microsoft.Win32.RegistryKeyregKey regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True) regKey.SetValue("YourApplicationName", "YourInstallPath") regKey.Close()
If you want to remove from register use this code.
Private Function CreatePictureArray(ByVal bImagePath As String) As Byte() Dim imgLogo As System.Drawing.Image = System.Drawing.Image.FromFile(bImagePath) Dim msLogo As New IO.MemoryStream() imgLogo.Save(msLogo, System.Drawing.Imaging.ImageFormat.Bmp)
Return msLogo.ToArray() End Function
5. Convert image to byte array and bind to datarow.
' Create new row Dim dr As DataRow = ds.Tables(0).NewRow dr("Title") = "Mr" dr("FirstName") = "Tom" dr("LastName") = "Brown" dr("Address") = "Tom Address" dr("Picture") = CreatePictureArray("c:\person.jpg")
3. Add new DataSet item. 4. Add DataTable in dataset design page and add data table columns. - Title, FirstName, LastName, Address
5. Add Crystal Report item by select report document as a blank report
6. On Field Explorer right click at Database Fields and select Database Expert.
7. Select Project Data -> ADO.NET DataSets and add customer table to ReportDataset.
8. Design Report (Add report header name txtHeader and report footer name txtFooter).
9. Sample code to show report. Private Sub btnShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShow.Click ' Get data to dataset Dim CustomerData As DataSet = CreateDataSet()
' Create report instance and set data to report data source Dim rpt As New CustomerReport rpt.SetDataSource(CustomerData.Tables(0))
' Access crystal report object ' Sample to access textbox object Dim txtHeader As CrystalDecisions.CrystalReports.Engine.TextObject = rpt.Section2.ReportObjects("txtHeader") txtHeader.Text = "This is Report Header"
Dim txtFooter As CrystalDecisions.CrystalReports.Engine.TextObject = rpt.Section2.ReportObjects("txtFooter") txtFooter.Text = "This is Report Footer"
' Show Report Me.CrystalReportViewer1.ReportSource = rpt
End Sub
Private Function CreateDataSet() As DataSet Dim ds As New DataSet("ReportDataset")
' Create Table Dim dt As New DataTable("Customer") dt.Columns.Add("Title", Type.GetType("System.String")) dt.Columns.Add("FirstName", Type.GetType("System.String")) dt.Columns.Add("LastName", Type.GetType("System.String")) dt.Columns.Add("Address", Type.GetType("System.String"))
' Add DataTable to DataSet ds.Tables.Add(dt)
' Create new row Dim dr As DataRow = ds.Tables(0).NewRow dr("Title") = "Mr" dr("FirstName") = "Tom" dr("LastName") = "Brown" dr("Address") = "Tom Address" ds.Tables(0).Rows.Add(dr)
Private Sub BackgroundWorker1_DoWork(ByVal sender As Object, ByVal e As DoWorkEventArgs) 'Sample how to disable button send before send email method after that enabled button. DisableSendButton() ' to do SendEmail method EnabledSendButton() End Sub
2. Show how to invoke method when use BackgroundWorker control.
Private Sub DisableSendButton() If Me.InvokeRequired Then Me.Invoke(New MethodInvoker(DisableSendButton)) Else btnSend.Enabled = False btnCancelSend.Visible = True End If End Sub
Private Sub EnabledSendButton() If Me.InvokeRequired Then Me.Invoke(New MethodInvoker(EnabledSendButton)) Else btnSend.Enabled = True btnCancelSend.Visible = False End If End Sub
A control is an object that can be drawn on to the Form to enable or enhance user interaction with the application. Examples of these controls, TextBoxes, Buttons, Labels, Radio Buttons, etc. All these Windows Controls are based on the Control class, the base class for all controls. Visual Basic allows us to work with controls in two ways: at design time and at runtime. Working with controls at design time means, controls are visible to us and we can work with them by dragging and dropping them from the Toolbox and setting their properties in the properties window. Working at runtime means, controls are not visible while designing, are created and assigned properties in code and are visible only when the application is executed. There are many new controls added in Visual Basic .NET and we will be working with some of the most popular controls in this section. You can select the controls from the menu towards the left-hand side of this page.
Notable properties of most of these Windows Controls which are based on the Control class itself are summarized in the table below. You can always find the properties of the control with which you are working by pressing F4 on the keyboard or by selecting View->Properties Window from the main menu.
The Control Class
The Control class is in the System.Windows.Forms namespace. It is a base class for the Windows Controls. The class hierarchy is shown below.
Object MarshalByRefObject Component Control ButtonBase, Etc, Etc Button, Etc, Etc
Main class is the Object class from which MarshalByRefObject class is derived and the Component class is derived from the MarshalByRefObject class and so on.
The properties of the Control object are summarized below. Properties are alphabetical as seen in the properties window.
Property
Description
AllowDrop
Indicates if the form can accept data that the user drags and drops into it
Anchor
Gets/Sets which edges of the control are anchored
BackColor
Gets/Sets the background color for the control
BackgroundImage
Gets/Sets the background image in the control
Bottom
Gets the distance bewteen the bottom of the control and the top of its container client area
Bounds
Gets/Sets the controls bounding rectangle
CanFocus
Returns a value specifying if the control can recieve focus
CanSelect
Returns a value specifying if the control can be selected
Capture
Gets/Sets a value specifying if the control has captured the mouse
CausesValidation
Gets/Sets a value specfying if the control causes validation for all controls that require validation
ContainsFocus
Returns a value specifying if the control has the input focus
ContextMenu
Gets/Sets the shortcut menu for the control
Controls
Gets/Sets the collection of controls contained within the control
Cursor
Gets/Sets the cursor to be displayed when the user moves the mouse over the form
DataBindings
Gets the data bindings for the control
Dock
Gets/Sets which edge of the parent a control is docked to
Enabled
Gets/Sets a value indicating if the control is enabled
Focused
Returns a value specifying if the control has input focus
Font
Gets/Sets the font for the control
ForeColor
Gets/Sets the foreground color of the control
HasChildren
Returns a value specifying if the control contains child controls
Height
Gets/Sets the height of the control
Left
Gets/Sets the x-coordinates of a control's left edge in pixels
Location
Gets/Sets the co-ordinates of the upper-left corner of the control
Name
Gets/Sets name for the control
Parent
Gets/Sets the control's parent container
Right
Returns the distance between the right edge of the control and the left edge of it's container
RightToLeft
Gets/Sets the value indicating if the alignment of the control's elements is reversed to support right-to-left fonts
Size
Gets/Sets size of the control in pixels
TabIndex
Gets/Sets the tab order of this control in its container
TabStop
Gets/Sets a value specifying if the user can tab to this control with the tab key
Tag
Gets/Sets an object that contains data about the control
Text
Gets/Sets the text for this control
Top
Gets/Sets the top coordinates of the control
Visible
Gets/Sets a value specifying if the control is visible
Width
Gets/Sets the width of the control
Control Tab Order
To move focus from one control to other quickly using the keyboard we can use the Tab key. We can set the order in which the focus is transferred by setting the tab order. The tab order is the order in which controls on the form receive the focus and is specified by the TabIndex property. To change the order in which a control receives focus we need to set the TabIndex property to different value for each control on the form. Lower values receive the focus first and proceed numerically through higher values. If there is a tie between TabIndex values, the focus first goes to the control that is closest to the front of the form. We can also set the tab order graphically with Visual Studio by selecting Tab Index from the View menu. Boxes containing current tab order appear in each control when you select Tab Index from View menu. Click each control to set the correct tab order in which you want the controls to receive focus.
When I use the TaskPad in Enterprise Manager to check a database's allocated, used, and free space (as reported on the General tab), the values I see don't match the values I get when I use the sp_HelpDB and sp_Spaceused stored procedures. For example, when I checked one of my databases today, I got the following information:
In TaskPad, Enterprise Manager reported that the database had 211549.75MB of allocated space, 110294.44MB of used space, and 101255.31MB of free space.
For the same database, the sp_Spaceused stored procedure told me I had 212113.50MB of allocated space and 19541.14MB of unallocated space.
The sp_helpDB stored procedure reported that I had an MDF file size of 211549.75MB.
Can I use T-SQL to return the same information that I see when I use the TaskPad?
To generate the information on the TaskPad, Enterprise Manager uses a combination of the following four queries.
Just as he was the first to talk about IE7, Bill Gates kept the tradition alive and discussed IE8 at the Mix ‘n Mash event here on campus yesterday. Bill was talking to some bloggers about IE.Next and called it IE8, the same way we do here in the IE team hallway.
So, yes, the version after IE7 is IE8. We looked at a lot of options for the product name. Among the names we considered and ruled out:
IE 7+1 IE VIII IE 1000 (think binary) IE Eight! iIE IE for Web 2.0 (Service Pack 2) IE Desktop Online Web Browser Live Professional Ultimate Edition for the Internet (the marketing team really pushed for this one ;-) Ie2.079 (we might still use this for the Math Major Edition)
Of course, some people care about other aspects of IE8 much more than they care about the name. As I’ve walked different people through the plan, I’ve gotten “Does it have feature X?” “When is the beta?” “When does it release” and even the more thoughtful “What are you trying to accomplish with this release?”
You will hear a lot more from us soon on this blog and in other places. In the meantime, please don’t mistake silence for inaction.
Thank you ieblog Dean Hachamovitch General Manager Published Wednesday, December 05, 2007 2:33 PM by ieblog
' Create file by FileStream class Dim fs As FileStream = New FileStream("c:\test.bin", FileMode.OpenOrCreate)
' Creat binary object Dim bf As New BinaryFormatter()
' Serialize object to file bf.Serialize(fs, pPerson) fs.Close()
' Open file and deserialize to object again Dim fsRead As New FileStream("C:\test.bin", FileMode.Open) Dim objTest As Object = bf.Deserialize(fsRead) fsRead.Close()
A TimeSpan object represents a time interval, or duration of time, measured as a positive or negative number of days, hours, minutes, seconds, and fractions of a second. The largest unit of time used to measure duration is a day. Time intervals are measured in days for consistency because the number of days in larger units of time, such as months and years, varies.
Sample Code
Dim dFirstDate As DateTime = DateTime.Now
' Add day Dim dLastDate As DateTime = DateTime.Now.AddDays(15)
' Subtract DateTime Dim pTimeSpan As TimeSpan = dLastDate.Subtract(dFirstDate)
' Compare DateTime Dim nResult As Integer = DateTime.Compare(dLastDate, dFirstDate) If nResult = 0 Then Console.WriteLine("First date is equals to Last date") ElseIf nResult > 0 Then Console.WriteLine("First date is lesser than the Last date") Else Console.WriteLine("First date is greater than Last date") End If
The Regex class contains several static methods that allow you to use a regular expression without explicitly creating a Regex object. Using a static method is equivalent to constructing a Regex object, using it once and then destroying it.
Sample Code 1
Imports System.Text.RegularExpressions ' import the namespace
'instantiate the objects dim oRegex as new regex("test pattern")
'use the object If oRegex.IsMatch("this is the string to test on") Then msgbox "Match found" else msgbox "Did not find match" end i
Sample Code 2
//Check for correct format of your name
Dim myMatch As Match = System.Text.RegularExpressions.Regex.Match(InsertYourName, "^[A-Z][a-zA-Z]*$")
If Not myMatch.Success Then
'Name was incorrect
ErrorMessage("Invalid Name", "Message")
txtFname.Focus()
Return
End If
Regular Expressions Elements:
* . Character except a newline character(\n) * \d Any decimal digit * \D Any nondigit * \s Any white-space character * \S Any Non-white-space charater * \w Any word character * \W Any nonword character * ^ Beginning of string or line * \A Beginning of string * $ End of string or line * \z End of string * | Matches one of the expressions seprated by the vertical bar; example eee|ttt will match one of eee or ttt (tracing left to right) * [abc] Match with one of the characters; example [rghy] will match r, g,h or c not any other character. * [^abc] Match with any of character except in list; example [ghj] will match all character except g,h or k. * [a-z] Match any character within specified range; example [a - c] will match a, b or c. * ( ) Subexpression treated as a single element by regular expression elements described in this table. * ? Match one or zero occurrences of the previous character or subexpression; example a?b will match a or ab not aab. * * Match zero or more occurences of the previous character or subexpression; example a*b will match b, ab, aab and so on. * + Match one or more occurences of the previous character or subexpression; example a+b will match ab, aab and so on but not b. * {n} Match exactly n occurrences of the preceding character;example a{2} will match only aa. * {n,} Match minimumn occurrences of the preceding character;example a{2,} will match only aa,aaa and so on. * {n,m} Match minimum n and maximum n occurrences of the preceding character;example a{2, 4} will match aa, aaa, aaaa but not aaaaa.
Visual Studio 2008 and the .NET Framework 3.5 will be available by the end of November 2007. The .NET Framework 3.5 will also be available to end users via a free, optional download from Microsoft Update. A CTP of Microsoft Sync Framework is available today at http://msdn.microsoft.com/sync. Popfly Explorer is a hosted development environment available today at http://www.popfly.com. More information about all of these releases is available at http://www.msdn.microsoft.com/vstudio. Founded in 1975, Microsoft (Nasdaq “MSFT”) is the worldwide leader in software, services and solutions that help people and businesses realize their full potential. Note to editors: If you are interested in viewing additional information on Microsoft, please visit the Microsoft Web page at http://www.microsoft.com/presspass on Microsoft’s corporate information pages. Web links, telephone numbers and titles were correct at time of publication, but may since have changed. For additional assistance, journalists and analysts may contact Microsoft’s Rapid Response Team or other appropriate contacts listed at http://www.microsoft.com/presspass/contactpr.mspx.
You can use ImportRow method to do this by calling NewRow adds a row to the table using the existing table schema, but with default values for the row, and sets the DataRowState to Added. Calling ImportRow preserves the existing DataRowState along with other values in the row. If the DataRow that is passed as a parameter is in a detached state, it is ignored, and no exception is thrown.
Sample Code
For Each dr As DataRow In sourceTable.Rows
destinationTable.ImportRow(dr)
Next
But if the destination table have the same structure you can use this clone method copies the structure of the DataSet that including all datatable schemas, relations, and constraints.
Sample Code
Dim dsDestination As DataSet ' clone method copies the structure of the DataSet, ' including all datatable schemas, relations, and constraints dsDestination = ds.Clone()
For Each dr As DataRow In ds.Tables(0).Rows dsDestination.Tables(0).ImportRow(dr) Next