Visual Studio 2005 - Warning in the Error List Window

T

Tom McL.

I'm trying to move a program that was designed using Visual Studio 2003 and
(Visual Basic) into Visual Studio 2005. When it runs I get the following
warning in the
Error List Window and I'm not sure how to correct it. The program runs fine
except for the warning. The warning puts a green squiggle line under
MyRecord
in the (Private Sub GetRecord()).

Warning Message:
Implicit conversion from 'System.ValueType' to 'MyProgram.mMyModule.Record'
in copying the value of 'ByRef' parameter 'Value' back to the matching
argument.
C:\Documents and Settings\Tom\My Documents\Visual Studio 2005\Projects\
MyProgram\fMyForm.vb 3700 34 MyProgram



Module level declare:
Public Structure Record
<VBFixedString(8)> Public filename As String
Public RainData(,) As Single
Public SnowData(,) As Single
Public SeasonToDateData(,) As Single
End Structure

Public myRecord As Record
End Module


Public Class fMyForm

Private Sub GetRecord()

Dim filenum As Short
Dim sFileName As String

'open file file and get record
sFileName = ListBoxFiles.Items.Item(1).ToString
filenum = FreeFile()
Try
FileOpen(filenum, Application.StartupPath & "/" & sFileName,
_
OpenMode.Random, OpenAccess.Read, OpenShare.Shared,
pRecLength)
FileGet(filenum, myRecord)
FileClose(filenum)
Catch ex As Exception
MsgBox(ex.ToString) ' Show friendly error message.
Finally
End Try
End Sub
End Class


Thanks

Tom
 
C

Cesar Ronchese

You double-clicked the green-underlined message so VS can show the error
line? If no, do it and post the block of code, please. I think the code you
posted is not that one it cause the message.

[]
Cesar
 
T

Tom McL.

Cesar,


This is the warning message I get when I hover over the
green-underlined variable:

Implicit conversion from 'System.ValueType' to 'MyProgram.mMyModule.Record'
in copying the value of 'ByRef' parameter 'Value' back to the matching
argument.

And it is the same message I see when I open the Error List Window.

The first block of code is my Module level declare of the structure named
Record.

Module level declare:
Public Structure Record
<VBFixedString> Public filename As String
Public RainData(,) As Single
Public SnowData(,) As Single
Public SeasonToDateData(,) As Single
End Structure

Public myRecord As Record
End Module


The second block is from my Public Class fMyForm.
The green-underlined variable is "myRecord" in "FileGet(filenum, myRecord)".
I hope
this is what you need.



Public Class fMyForm

Private Sub GetRecord()

Dim filenum As Short
Dim sFileName As String

'open file file and get record
sFileName = ListBoxFiles.Items.Item(1).ToString
filenum = FreeFile()
Try
FileOpen(filenum, Application.StartupPath & "/" & sFileName,_
OpenMode.Random, OpenAccess.Read, OpenShare.Shared,pRecLength)

FileGet(filenum, myRecord)
FileClose(filenum)
Catch ex As Exception
MsgBox(ex.ToString) ' Show friendly error message.
Finally
End Try
End Sub
 
C

Cesar Ronchese

I need the FileGet( ) signature, I'm looking for the ByRef and ByVal tip.
You tried change all the parameters of that function to ByVal to see if it
works?
 
C

Cesar Ronchese

Can you build a sample (some pieces of code) and post a link here? This
sample need to have that mencioned issue, so we can simulate the error and
try discover the cause.

[]s
Cesar
 
S

strchild

I'm receiving the same warning, and although this has been brought up
several times by other posters, I can't find the solution anywhere. I've
Googled and searched the newsgroups, but I'm at a loss as to the solution.

I create my own structure, then use it when I read from a file, but get the
warning each and every time I do so.
Structure addressEntry

<VBFixedString(ciSalesperson)> Public sSalesperson As String

<VBFixedString(ciBillingAddress1)> Public sBillingAddress1 As String

<VBFixedString(ciBillingAddress2)> Public sBillingAddress2 As String

<VBFixedString(ciBillingAddress3)> Public sBillingAddress3 As String

<VBFixedString(ciShippingAddress1)> Public sShippingAddress1 As String

<VBFixedString(ciShippingAddress2)> Public sShippingAddress2 As String

<VBFixedString(ciShippingAddress3)> Public sShippingAddress3 As String

End Structure

.. . .

Private Sub LoadAddress()

If Not Blank(comboboxBillToLine1.Text) Then

Dim Address As New addressEntry

Dim f As Integer = FreeFile()

FileOpen(f, sDataDirectory & "\address.dat", OpenMode.Random, , ,
Len(Address))

For l As Long = 1 To (LOF(1) \ Len(Address))

FileGet(f, Address, l)

If comboboxBillToLine1.Text.TrimEnd.ToLower =
Address.sBillingAddress1.TrimEnd.ToLower Then

textboxBillToLine2.Text = Address.sBillingAddress2.TrimEnd

textboxBillToLine3.Text = Address.sBillingAddress3.TrimEnd

textboxShipToLine1.Text = Address.sShippingAddress1.TrimEnd

textboxShipToLine2.Text = Address.sShippingAddress2.TrimEnd

textboxShipToLine3.Text = Address.sShippingAddress3.TrimEnd

textboxSalesperson.Text = Address.sSalesperson.TrimEnd

Exit For

End If

Next

FileClose(f)

End If

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top