Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting a VBScript program to VB2008 Express Edition 1

Status
Not open for further replies.

DPlank

IS-IT--Management
May 30, 2003
1,903
GB
Hi guys,

I'm new to the whole .NET thing - Not even technically a programmer. I've been tasked with converting some code from a .vbs file to a VB .net application. I've hit a slight problem. The code interacts with an AttachMate client (terminal emulator) to grab text from the screen (see vbs code below)
Code:
For iRow = 1 To oSCREEN.Rows
            sRowText = oSCREEN.GetString(iRow, 1, oSCREEN.Cols) & vbNewLine
            sRowText = Replace(sRowtext,vbNewLine,"")
            If Len(iRow) = 1 Then 
                sRow = "0" & iRow
            Else
                sRow = iRow
            End If
            oSCREENLOG.WriteLine sRow & " --" & sRowText & "++"
            If sScreenText <> "" Then
                sScreenText = sScreentext & vbNewLine
            End If
            sScreenText = sScreenText & sRowText
        Next

The problem I'm hitting is in the oSCREEN.GetString line.
I'm getting an exception which reads:
System.Runtime.InteropServices.COMException was unhandled
ErrorCode=61837
HelpLink="C:\Program Files\E!PC\EXTRA.HLP#455053"
Message="Unable to write read-only property."
Source="hà `"

The intellisense doesn't show me GetString as an option for the oSCREEN (which is initially defined in the class being used)
Code:
 oEXTRA = CreateObject("EXTRA.System")
        oSESSIONS = oEXTRA.Sessions
        'Set oSESSION = oSESSIONS.Open("C:\Program Files\E!PC\Sessions\BACKDCMS.EDP")

        If oSESSIONS.Count > 0 Then
            oSESSION = oEXTRA.ActiveSession
            oSCREEN = oSESSION.Screen
        End If

Do I need to somehow extend the "Extra.System" class to make this method available, or somehow include it from somewhere? Create a new class and inherit the Extra.System bit into it? Suggestions and solutions are welcomed - the Extra help file was no use, as it clearly shows the GetString method is being used correctly..



Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
In your .net app have you added the reference to the third party com object?
 
Also you check that you have the Import at the top of the page unless you're fully qualifying the reference.
 
That'd be a pair of 'no's. I'm wading through the help file trying to find out how to do that now though...


Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
In your vb.net application (VB2008) there should be a menu item View->Solution Explorer

From that it should bring up a list of the files in the solution/project. Expand the project that you want to reference the COM object in and there should be a References folder. Right click on that select Add Reference then a dialog box should appear. Select the COM tab (assuming that it is a COM object and that it has been registered). The object should then appear in the list. Select it and press ok.

This will have added the reference.
 
Ok. Found the reference to AttachMate Extra and added it to the project.

Added a line reading: Imports EXTRA at the top of the code (just after the option explicit on and before the class definition)

Still getting the same error, sadly...

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
Next question would be is sRowText declared?

Also does intellisense pick up the getstring method now?
 
Yep, all variables are declared correctly.

But no, Intellisense doesn't pick up the GetString.

I've checked another one (oSCREEN.Rows) and it's not visible in intellisense either, but it's working and returning the correct value.

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
Looking at the exception detail Has this listed under the Item tag: In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.

I'm not certain what it's referring to, though. Any ideas?

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
For this I would guess (I'm a c# programmer not really VB)

oSCREEN.GetString(iRow, 1, oSCREEN.Cols)

would require iRow and oScreen.Cols to be cast as the specific datatypes.

From the code I am guessing that iRow is an Integer and that oScreen.Cols will be a string.

It might be worth (as a test) using something like

oSCREEN.GetString(1, 1, "test")

debug this using a breakpoint and see if it does set sRowText to a value. (Also just check that the index starts at 1 (it could start from 0) and that the oScreen.Cols can be a string and not just a char.

If this works then it might be worth using
oSCREEN.GetString(CINT(iRow), 1, oSCREEN.Cols)

i think CINT is the syntax (basically convert to an integer)
 
The CInt addition did it - it's now working correctly.

Many many thanks!

Cheers,
Dave

"Yes, I'll stop finding bugs in the software - as soon as you stop writing bugs into the software." <-- Me

For all your testing needs: Forum1393
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top