Monday, February 6, 2017

TEXTBOX TO MSFLAXGRID CODE ..VB6.0

TEXTBOX TO MSFLAXGRID CODE 
Here is a code of VB6.0 for entering data from textbox to msflexgrid. It is very use full in any form for saving huge data of the same nature. It holds and display the data from text box to the grid.It is easy and best way to display multiple data. Here I am going to write a code for only entering data to MSflexGrid from textbox , not from the database. It is only front display of data from textbox to MSflexgrid.
Open the Projects  and drag the controls as show in the image.





Then add components clicking on Project Menu...........................


Then , select MicroSot MSFlexGrid Contorl and press Apply and OK.



Then you can see controls on the left side of the project screen.
You drag to the form you want to display
Then you can clear the textbox in design time or you can clean them on run time using below code
Textbox1.text =””
It mean this will clear the text box .
Now Input the data to the textbox. Now then you have to decide when to input data to the grid of textbox. I have made here input data on keypress event of last textbox.
Here is the code ,
If KeyAscii = 13 Then
If KeyAscii = 13 Then
    X = MSFlexGrid1.Rows
    MSFlexGrid1.Rows = MSFlexGrid1.Rows + 1
    MSFlexGrid1.TextMatrix(X, 0) = MSFlexGrid1.Rows - 1
   MSFlexGrid1.TextMatrix(X, 1) = Text1.Text
   MSFlexGrid1.TextMatrix(X, 2) = Text4.Text
   MSFlexGrid1.TextMatrix(X, 3) = Text5.Text
   MSFlexGrid1.TextMatrix(X, 4) = Text3.Text
End If
In the design view , Msflexgrid property ,define col as 5.
Then , row as 1. Then you can input data to the msflexgird from textbox to the grid.




Simple and easy. Enjoy the code.
Questions if necessary and please suggest me if you want more me to do.

Thank you .

Narayan Arjyal
Butwal

Nepal 

No comments:

Post a Comment