VB6 Read Text File

With this artcle, I am going to explain various ways we can Read Text File into a string variable using Classic VisualBasic.

The first and easy way to acess a txt file is using the simple open method available in VB. For this method, we need to allocate a unique file number for opening. And the same number should be used to close.

There are various modes to open some of them are Append, Binary, Input, Output, or Random. by default Random will be used.

In this code I have closed the connection after error has been handled(or intended to be handled). This close method  will not do anything if the file number is not used to open. so it is safe even error has been occured before opening.

Using FileSystemObject in VB6 Read Text File

With FileSystemObject File IO operations are very easier in VB. Almost all the required functions are well defined. For reading, we hav ...

Read more here:   Read Text File into string VB6 

06-Aug-2010

ASP.Net Calendar with JavaScript as a DatePicker

Is there a DatePicker control in the ASP.Net 2.0? No, so I started writing some code which will be similar to the Win Forms DatePicker. The best approach is to build a server control or al least a user control. This article describes how to use JavaScript to get this functionality so that later on this can be ported to a user control.

Controls required for a DatePicker

I have planned to use a textbox to accept the dates, calendar to select dates, a panel to contain the calendar and a button to show, or hide the calendar control and its panel. I preferred to use the html button and div as a panel.

JavaScript Functionalities

This DatePicker is designed with the aim of improving the usability in to consideration. Still there are various functionalities can be added but for explaining the core working functionalities without making too much of confusions, I have opted only the following functionalities. ...

30-Jul-2010

Write a text file from string

This is a sample program to write text file from string. The string should be well formed, The string will be written as it is. So the line breaks should be placed when prearing the string before passing it to the function.

Visual basic is a nice language to write a simple File.Io operations. It is not only simpler to write but also very easy to debug. Using this kind of helpers can improve the code re-usablity also.I have written already a lot of articles related to File operations like reading file, searching files using regular expressions.

There are various ways to read write files.  I prefer the file system objects to handle the file system, As it looks very neat and easy to be handled. When ever working in file stream it is really necessary to close the stream. Otherwise it will be really not efficient.

By using the IsOverwrite parameter we can append text to the existing file. If IsOverwrite is false then the tex ...

Read more here:   Write a text file from strings 

29-Jul-2010

WPF DataGrid Bind with Dataset

Initially when I looked the WPF Toolbox I couldn’t locate the GridView. So I started looking for some equivalents. The closest to what I need was the ListBox. So I had decided to use it for my Media Player.

Need of separate Toolkit from CodePlex

After some point of time I have searched for the WPF DataGrid . I have found the Tool Kit from the CodePlex. Ok now if we need a DataGrid it is not shipped with framework. So we need to download from CodePlex. I have downloaded the binaries. It is a MSI package. So I have installed it. It will not be available in the tool box right after installation, you have to choose the installed component to be listed in the toolbox. 

So to get DataGrid on Toolbox we need select from the list of components. This is available in the “Choose Tool Box Item” dialog box and under the WPF Components section.
&n ...

Read more here:   WPF DataGrid Bind DataSet 

28-Jul-2010

Grouping data in the ASP.Net GridView

 Presenting a grouped data in the standard GridView is really a tough task to get it to a satisfactory level. If you ever worked in Spreadsheets to group the data, you may have seen that the merge functionality gives a very good presentation for the grouped data

Note:

1) As it is already explained in earlier articles several times, I am not going to explain again how to get the data and how to bind the data from database. So please refer to the Asp.net DataControls section or GridView section for that matter.
2) Northwind database is used for samples, this database can be downloaded from MSDN
3) This sample is to explain how to have this merge functionality using row span attribute of the cell. So it may be a tough task to extend this task to get two or more columns to have this merge functionality.

RowSpan and ColSpan in HTML TD

In HTML TD we can use the COL span to spread a single ...

Read more here:   ASP.Net GridView Group Rows 

23-Jul-2010

Calendar in a GridView template

Unlike other controls, calendar is taking too much of space for its usage. In most of the applications calendar will be hidden just after selecting the date. Earlier days in classic asp, we used a popup to load it on demand (sometimes used inline as well).  Here in this sample we are going to use a calendar control inside a GridView’s TemplateField. To make it close to real time, I have added a Textbox and a button to pop the calendar.

Show Hide calendar

As already explained to reduce the space used by calendar, it is easier to toggle visibility using a JavaScript. Since the calendar control is going to be at each row, the respective control’s client ids have to be passed. Otherwise we can not access those controls from JavaScript.

Attach Client Events at RowDataBound

To pass the Client ID’s of all the required controls to JavaScript, the right place is the RowDataBound event. This event will be fired for every ...

Read more here:   Asp.net GridView Calendar 

20-Jul-2010

ListView and Templates

ListView is a fantastic control when you want to render the tabular data in a customized way. It gives you a lot of templates to work with. These templates will improve the most used functionalities. This article explains about one of them, which is GroupTemplate.

What is not covered?

The basic functionalities of ListView and how to bind the data to DataSource from SQL database are not covered in this article. Please refer to the ASP.Net Data Controls section for that.

LayoutTemplate

This template is used mainly for determining the basic layout the control supposed to render. So in our case this will hold the groups. Further groups hold their respective items. Hence we need to specify the GroupPlaceholderID to the layout template not to the GroupTemplate.  I have placed a silver colored (as a background) box to contain all group boxes.

GroupTemplate

As I already mentioned in the previous paragraph, we sup ...

Read more here:   ASP.net ListView GroupTemplate 

16-Jul-2010

A Customized DataList Paging

If you ever worked in GridView, you will be amazed with the native functionalities that GridView offers. But DataList is not loaded with that many features. It is basically meant for binding data in a tabular format.  If there is a need of sorting, paging then we need to write our own code to cater those needs.

Note:
1) As it is already explained in earlier articles several times, I am not going to explain again how to get the data and how to bind the data from database. So please refer to the Asp.net DataControls section or GridView section for that matter

2) This sample is written to explain how to rollout a paging support for DataList. It may not suit your real-time situation as it is.  You may need to code to make it better for real time situations.

Limitations on DataList Paging

1) There is no native paging support for the DataList.
2) There is no DataPager support, (those ...

Read more here:   ASP .Net DataList Paging 

18-Jun-2010

DataBinding GridView with Asp.net Array List

DataBinding is an integral part in developing GUI intensive applications. It really eases the job of populating the data into the control from respective DataSource. The DataSource is usually being an IEnumerator. Means all the objects that implement an IEnumerator can be used to bind the controls.
GridView DataBinding
Though Binding a GridView is very simple task in VB.Net, the following is essential. Understanding
• how to use a DataSource
• Once the DataSource is given how to bind the data.
Why ArrayList over Array?
The reason behind I have chosen ArrayList over array is, because of the ease of use. The array needs to be re dim every time when the number of elements is changed. If you want to add a new item then you have to re dim the array.
But ArrayList are much easier to work with. The reason behind is, it is something like collection in Classic VB. You can ...

15-Jun-2010

Freeze ASP.Net GridView Columns and Header with CSS

When working in large spreadsheet in excel I used to freeze the columns(including First Column) and rows. This is very useful when you want to compare the values in one column with other column values. And regarding header I always freeze it otherwise it is very hard to find what the values are referring to.

Like spreadsheet the GridView as well displaying the data in the tabular format. But unfortunately there is no support for this freezing functionality. What i dislike is, there is no built in support for GridView scrolling. we need to write our own CSS to control this.

So I started looking for an alternative while I found some and I wanted to derive a custom container control which can hold a GridView inside and you can specify the columns to freeze. But the developmen ...

14-Jun-2010