Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8116997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:00:36+00:00 2026-06-06T04:00:36+00:00

I can’t get to pass structure as argument through subs/functions in different files of

  • 0

I can’t get to pass structure as argument through subs/functions in different files of single vbnet project like I use to in earlier MS basic versions.
Here is short example of situation:

Module1.vb

Imports System.IO

Structure mymultitry
     Dim index As Integer
    <VBFixedString(6)> Dim name As String
    Dim weight As Double
End Structure

Module Module1
Public mysetupfile = "mysetup.dat"

Public Sub rwfile(ByVal rw As Integer, ByVal myrecord As Integer, ByVal mmt As mymultitry)

'EDIT: Thanks to SteveDog - proper line should be:
'Public Sub rwfile(ByVal rw As Integer, ByVal myrecord As Integer, ByRef mmt As mymultitry)

    Dim fnum As Integer
    fnum = FreeFile()
    FileOpen(fnum, mysetupfile, OpenMode.Random, OpenAccess.ReadWrite, OpenShare.Shared, Len(mmt))
    If rw Then
        FilePut(fnum, mmt, myrecord)
    Else
        FileGet(fnum, mmt, myrecord)
    End If
    FileClose(fnum)
End Sub

End Module

Form1.vb

Public Class Form1
Dim mmt As mymultitry
Dim mmt1 As mymultitry

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    With mmt
        .index = 4
        .name = "Helga"
        .weight = 128.1445
    End With
    rwfile(1, 1, mmt)  'write

    rwfile(0, 1, mmt1) 'read

    'all zero here !?!
    Debug.Print(mmt1.index)
    Debug.Print(mmt1.name)
    Debug.Print(mmt1.weight)

End Sub
End Class

File “mysetup.dat” is reachable and data is saved correctly what I can see with HxD.
But read part seem’s to not work as expected.

Please any help on reliable passing structure as argument without too much public elements based on upper example.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T04:00:38+00:00Added an answer on June 6, 2026 at 4:00 am

    I strongly suggest you rewrite your code to use the new .NET IO methods in the System.IO.File class, but, that aside, I think your problem with your existing code is that you need to change your mmt argument from ByVal to ByRef.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I run this in a Windows command prompt like I can run it
Can MOSS integrate and get user profiles from multiple Active Directory and/or LDAP stores?
Can anyone tell me what i am doing wrong? I am trying to get
Can we pass ArrayLists as arguments to methods in C#?
Can we put functions to determine the condition for our list comprehensions. Here is
Can't seem to get the Back Button to appear in a UINavigationController flow. I
Can i get the source code for a WAMP stack installer somewhere? Any help
Can you cast a List<int> to List<string> somehow? I know I could loop through
Can anyone tell me how I can display a status message like 12 seconds
Can epoll (on Linux) be somehow useful for regular files? I know it's primarily

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.