Click here to Skip to main content
15,920,632 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionMouse Movement in VB 6.0 Pin
zawpai26-Dec-07 14:59
zawpai26-Dec-07 14:59 
GeneralRe: Mouse Movement in VB 6.0 Pin
Dave Kreskowiak27-Dec-07 12:27
mveDave Kreskowiak27-Dec-07 12:27 
Question[Message Deleted] Pin
ciconte26-Dec-07 14:28
ciconte26-Dec-07 14:28 
GeneralRe: Terms of use and e-mail subscription Pin
Dave Kreskowiak27-Dec-07 12:21
mveDave Kreskowiak27-Dec-07 12:21 
GeneralRe: [Message Deleted] Pin
Paul Conrad30-Dec-07 10:45
professionalPaul Conrad30-Dec-07 10:45 
GeneralExport Excel Sheet to Textfile (vb.net) Pin
Member 375080126-Dec-07 13:45
Member 375080126-Dec-07 13:45 
GeneralRe: Export Excel Sheet to Textfile (vb.net) Pin
Paul Conrad30-Dec-07 10:46
professionalPaul Conrad30-Dec-07 10:46 
QuestionRe: Export Excel Sheet to Textfile (vb.net) Pin
Member 37508012-Jan-08 7:08
Member 37508012-Jan-08 7:08 
Hi Paul,

I am trying to export each cell value as opposed to getting a whole row at a time, as they go to specific positions in the text file. Here's what i have now and i get

"Unable to cast COM object of type 'System.__ComObject' to class type 'System.Array'.
Error on line with--->" For r = 1 To UBound(arr, 1)". Can you help?

   Sub MakeFixedWidth()<br />
<br />
        Dim oXL As New Excel.Application<br />
        Dim oWBK As Excel.Workbook = oXL.Workbooks.Open("\\nycapps01\DevFiles\SeamlessDev\Excel2Text\SampleInvoice8.xls")<br />
        Dim oWS As Excel.Worksheet = CType(oWBK.Worksheets(1), Excel.Worksheet)<br />
<br />
<br />
        'Dim Sizes As Object<br />
        Dim arr As Object<br />
        Dim r As Long ', c As Long<br />
        Dim fso As Object<br />
        Dim ts As Object<br />
        Dim TheLine As String<br />
        'Dim TestStr As String<br />
<br />
        Dim names As Object = Array.CreateInstance(GetType(Integer), 10, 8, 10, 8, 10, 8, 10, 8)<br />
<br />
        'Sizes = Array(4, 2, 45)<br />
        arr = oWBK.ActiveSheet.UsedRange<br />
<br />
        fso = CreateObject("Scripting.FileSystemObject")<br />
        ts = fso.CreateTextFile("c:\blah.txt", True)<br />
<br />
        For r = 1 To UBound(arr, 1)<br />
            TheLine = Space(51)       ' your fixed-width output<br />
<br />
            Mid(TheLine, 1, 10) = oWS.Cells(r, 1)<br />
            Mid(TheLine, 11, 8) = oWS.Cells(r, 1)<br />
            Mid(TheLine, 19, 10) = oWS.Cells(r, 1)<br />
            Mid(TheLine, 29, 8) = oWS.Cells(r, 1)<br />
            Mid(TheLine, 37, 10) = oWS.Cells(r, 1)<br />
            Mid(TheLine, 47, 8) = oWS.Cells(r, 1)<br />
            Mid(TheLine, 55, 10) = oWS.Cells(r, 1)<br />
            Mid(TheLine, 65, 8) = oWS.Cells(r, 1)<br />
            ts.WriteLine(TheLine)<br />
<br />
        Next r<br />
<br />
        ts.Close()<br />
<br />
        ts = Nothing<br />
        fso = Nothing<br />
<br />
        MsgBox("Done")<br />
<br />
    End Sub

GeneralBetter way of connecting to SQL 2005 Pin
svanwass26-Dec-07 13:31
svanwass26-Dec-07 13:31 
GeneralRe: Better way of connecting to SQL 2005 Pin
Dave Kreskowiak27-Dec-07 12:17
mveDave Kreskowiak27-Dec-07 12:17 
QuestionClass disposal Pin
__OZ__26-Dec-07 10:33
__OZ__26-Dec-07 10:33 
GeneralRe: Class disposal Pin
Dave Kreskowiak26-Dec-07 10:59
mveDave Kreskowiak26-Dec-07 10:59 
GeneralRe: Class disposal Pin
__OZ__26-Dec-07 15:10
__OZ__26-Dec-07 15:10 
GeneralRe: Class disposal Pin
Scott Dorman26-Dec-07 17:55
professionalScott Dorman26-Dec-07 17:55 
QuestionHow to work with Collection in VB6? Pin
suguimoto26-Dec-07 6:48
suguimoto26-Dec-07 6:48 
AnswerRe: How to work with Collection in VB6? Pin
Paul Conrad26-Dec-07 7:43
professionalPaul Conrad26-Dec-07 7:43 
AnswerRe: How to work with Collection in VB6? Pin
Dave Kreskowiak26-Dec-07 8:08
mveDave Kreskowiak26-Dec-07 8:08 
GeneralRe: How to work with Collection in VB6? Pin
suguimoto26-Dec-07 8:55
suguimoto26-Dec-07 8:55 
GeneralRe: How to work with Collection in VB6? Pin
Dave Kreskowiak26-Dec-07 9:05
mveDave Kreskowiak26-Dec-07 9:05 
GeneralRe: How to work with Collection in VB6? [modified] Pin
suguimoto26-Dec-07 23:44
suguimoto26-Dec-07 23:44 
GeneralRe: How to work with Collection in VB6? Pin
Dave Kreskowiak27-Dec-07 5:09
mveDave Kreskowiak27-Dec-07 5:09 
QuestionInstance of existing form and control manipulation Pin
Adnan Siddiqi26-Dec-07 6:21
Adnan Siddiqi26-Dec-07 6:21 
GeneralRe: Instance of existing form and control manipulation Pin
Dave Kreskowiak26-Dec-07 8:13
mveDave Kreskowiak26-Dec-07 8:13 
GeneralDataGridViewTextBoxEditingControl Pin
helelark12326-Dec-07 4:54
helelark12326-Dec-07 4:54 
GeneralRe: DataGridViewTextBoxEditingControl Pin
Dave Kreskowiak26-Dec-07 6:56
mveDave Kreskowiak26-Dec-07 6:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.