VB.Net Tutorial - BackgroundWorker and InvokeThose who have worked extensively on threading will feel that this article is simple. But for who are quite new to threading and learning the Asynchronous operations, this article can be useful to figure out how to introduce the Asynchronous to the existing methods to enhance the performance. Why there is a need of Asynchronous or BackgroundWithout the BackgroundWorker worker, you can still build a good application. However with the help of asynchronous operations, you can improve the processing time and hence the application will be highly responsive. Run the source code sequential I can prove that with the example I have given in this article. If you look at the source code event btnStart_Click, I have commented out the function BgWorkerFunction. To run without asynchronous you may comment out the BackgroundWorker1.RunWorkerAsync() function call and uncomment the BgWorkerFunction call. Now you can ...
|
VB.Net Tutorial - ComboBox AutoCompleteModeComboBox control is similar to ListBox control, in which you can select one item from a list of items. But it takes less space on screen and it allows you to locate an item by setting value to the ComboBox control’s text property. In simple word, it is an expandable(collapse/expand) ListBox control. AutoCompleteMode PropertyHere we are going to see the AutoCompleteMode property in ComboBox control. This property automatically matches the input string given on runtime (starts with match) of all strings in the source database column. Based on that it will display the matched string in ComboBox. This property is very useful for frequently searching strings. Such as URLs, file name, customer name, or any command that is frequently used. This property go well when there is no duplication in source data. If there is duplication occurs in source data then the AutoCompleteMode property omits the duplication an ...
|
VB.Net Tutorial - Datagridview PrintingThere will be situations to just print a DataGridView in a application than designing again the columns and rows in a Crystal Report. But in .Net there is no straight forward way to do this or in other words this is not supported natively. To print the Datagridview we need to draw all the objects using Graphics Object given in the PrintDocument before calling print method in the respective PrintDocument. PrintDocument and the Graphics ObjectSo as I earlier said we need to actually draw all including text using the Graphics object. The print document needs to be prepared before actual printing starts. So we can use the event PrintPage, in this event we can draw all the objects as we need. Draw the DataGridView like a table using linesTo get a tabular data to represent the DataGridView, we need to do the following • Draw an outer rectangle as the border to table • Draw a line for every ...
|
VB.Net Tutorial - Read Text File using VB6In classic VB reading a file is not that easy as we do in vb.net. The first and easy way to access a text file is using the simple file open method available in classic Visual Basic. Using this method, we can allocate a unique file number for opening the file. further the same number has to be used for closing the file handle.
In addition to this, there are various modes a file can be opened. Some of them are Append, Binary, Input, Output, or Random. By default Random will be used.
Read text file in VB.Net In VB.net we can read files very easily. The System.IO namespace contains really very useful set of functions which can reduce the effort and time in coding file related activities. One of the easiest is reading a text file into string System.IO.File.ReadAllText(FilePath). Source codeForm1.Vb
|
VB.Net Tutorial -WebClient Object The great helpful thing about developing with .NET is, a lot of objects introduced in .Net framework.One of them is this web client object. Earlier days we need to send the XmlHttp request or Web Request to send the request and receive the response. WebClient not only reduced the effort in downloading text, but also helpful in a lot of areas such as security and form submission etc…
DownloadStringAs I said before the download string function makes the life easier. You can simply pass the URL to this function and it will return the response text. If the resource is secured you can send the Network Credentials to authenticate, Dim webClient As New WebClient() Dim Downloaded= webClient. DownloadString(URI)
HTML Head Title Access DeniedNow that is the error we are receiving, means that the access is denied while calling the resource. So we need to authenticate. Use the following to authenticate. The R ...
|
VB.Net Tutorial -Drawing libraries‘System.Drawing’ can be one of the fun working libraries for working on interesting tasks like imaging. This is loaded with a lot of features that can make the drawing and imaging activities much easier. Dealing with BitmapI usually prefer to work with bitmap when I am working on the imaging. The reason behind is, it has a lot of properties and methods to work with. We can easily save, change the pixel, and retrieve the pixel. Drawing TextsJust like drawing the lines, pixels, circles on an image, it is very easy to write a text on the image using graphic object’s DrawString() method. This graphic object has to be based on the image where we are going to write to. So use the FromImage function of the Graphics to get the graphics object of the image. Formatting with Graphics Graphics object can be used to format the image, text. So use the properly suited overloaded method to handle the requ ...
|
VB.Net Tutorial - Close running processes .Net made it very easy for handling processes. It is much easier to close the applications using Process.Kill(). Processes can be iterated using the ‘for each’ loop. The process object taken from enumeration has enough methods and properties to deal with processes. Get the list of processesTo get the list of instances running with the current applications name, we can use the Process.GetProcessesByName(“ProcessName”). This method returns collection of processes with the name “ProcessName”. Thereafter accessing each process is easy with a ‘for each’ loop. Kill other processes running under same nameI had a requirement to ensure that, current process is the only running process. The rest of the other instances of the processes have to be closed. Using the GetProcessesByName method we can get the list of current instances. While iterating thro the collection, we can identify the current process ...
|