Sample codes for vb6 text file insert row.

Asked By 0 points N/A Posted on -
qa-featured

Hello experts,

I am working out for my visual basic programming language project and I need to insert a row. Can you help me with this?I need a sample codes for vb6 text file insert row. Can I download it for free in the internet as a reference?

SHARE
Best Answer by Mundo Villaro
Best Answer
Best Answer
Answered By 0 points N/A #130604

Sample codes for vb6 text file insert row.

qa-featured

 

Hello James,
 
You must specify what row you are referring to, is it in ms access or ms excel? For excel, you may consider this sample code I have.
 
Option Explicit
 
'Add reference to MS Excel xx.0 Object Library
 
Private moApp As Excel.Application
Private Sub Command1_Click()
Dim oWB As Excel.Workbook
Dim lMaxRowNumber As Long
moApp.Visible = True
Set oWB = moApp.Workbooks.Open("D:My DocumentsBook1.xls")
'Add first new row at the very end
lMaxRowNumber = oWB.Sheets("Sheet1").Cells.SpecialCells(xlCellTypeLastCell).Row
oWB.Sheets("Sheet1").Rows(CStr(lMaxRowNumber + 1) & ":" & CStr(lMaxRowNumber + 1)).Select
Application.Selection.Insert Shift:=xlDown 'Insert a row at the selection (last row + 1)
oWB.Sheets("Sheet1").Cells(lMaxRowNumber + 1, 1).Value = "Added new row"
'Add another new row at the new very end
lMaxRowNumber = oWB.Sheets("Sheet1").Cells.SpecialCells(xlCellTypeLastCell).Row
oWB.Sheets("Sheet1").Rows(CStr(lMaxRowNumber + 1) & ":" & CStr(lMaxRowNumber + 1)).Select
Application.Selection.Insert Shift:=xlDown
oWB.Sheets("Sheet1").Cells(lMaxRowNumber + 1, 1).Value = "Added second new row"
End Sub
Private Sub Form_Load()
Set moApp = New Excel.Application
 
End Sub
Answered By 0 points N/A #130605

Sample codes for vb6 text file insert row.

qa-featured

Using System. IO operation you’ll be able to write to a text file. Code mentioned in below link will search for a text file available in the physical location on your hard drive and will write text to the file. Newly added text will be appended and not over written. You can check the code in below link:

Login/Register to Answer

Related Questions