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 7590511
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:25:10+00:00 2026-05-30T20:25:10+00:00

I have some VB6 code that needs to be migrated to VB.NET, and I

  • 0

I have some VB6 code that needs to be migrated to VB.NET, and I wanted to inquire about this line of code, and see if there is a way to implement it in .NET

Dim strChar1 As String * 1

Intellisense keeps telling me that an end of statement is expected.

  • 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-05-30T20:25:12+00:00Added an answer on May 30, 2026 at 8:25 pm

    That’s known as a "fixed-length" string. There isn’t an exact equivalent in VB.NET.

    Edit: Well, OK, there’s VBFixedStringAttribute, but I’m pretty sure that exists solely so that automated migration tools can more easily convert VB6 code to VB.NET for you, and it’s not really the ".NET way" to do things. Also see the warnings in the article for details on why this still isn’t exactly the same thing as a fixed-length string in VB6.

    Generally, fixed-length strings are only used in VB6 if you are reading fixed-size records from a file or over the network (i.e. parsing headers in a protocol frame).

    For example, you might have a file that contains a set of fixed-length records that all have the format (integer, 1-character-string, double), which you could represent in VB6 as a user-defined type:

    Public Type Record
       anInteger As Integer
       aSingleCharacter As String * 1
       aDouble As Double
    End Type
    

    This way, VB6 code that reads from the file containing records in this format can read each fixed-sized record stored in the file, and in particular, it will only read 1 byte for aSingleCharacter. Without the * 1, VB6 would have no idea how many characters to read from the file, since a String can normally have any number of characters.

    In VB.NET, you can do one of the following, depending on your needs:

    • If the length matters (i.e. you need to read exactly one byte from some data source, for example) consider using an array instead, such as

      Dim aSingleByteArray(1) As Byte

    • Alternatively, you could use one of the Stream classes. In particular, if you are reading data from a network socket or a file, consider using NetworkStream or FileStream, respectively. A Stream is meant for byte-for-byte access (i.e. raw binary access). StreamReader is a related class that simplifies reading data when it is text-based, so that might be good if you are reading a text file, for example. Otherwise (if dealing with binary data), stick with one of the Stream classes.

    • If the length doesn’t matter, you could just use a "normal" String. That is to say:

      Dim aNormalString As String

    Which answer is "correct" really depends on why it was declared that way in the original VB6 code.

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

Sidebar

Related Questions

I have some VB6 code that I am converting to VB.net and came across
I have some old code (an old but still maintained VB6 application) that from
We have a VB6 app that launches our .NET code upon startup. Cold start
I have some .NET code I use from VB6 code. I have always developed
I have some query about my code, I am using VB6.0 and I have
I have some vb6 code that is stubbornly writing to Windows-1252. Open fileName For
In some VB6 code, I have a handler for a TreeView's Collapse event: Private
Hi I have some software written in VB6.0 that uses an SQL Server, but
I am doing some maintenance on a VB6 Windows application. I have a .Net
I have some code for starting a thread on the .NET CF 2.0: ThreadStart

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.