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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:45:52+00:00 2026-06-11T20:45:52+00:00

In a recent question, Import a VB6 structure into C# , the code contained

  • 0

In a recent question, Import a VB6 structure into C#, the code contained a fixed-length string similar to this:

Name As String *10

There was some discussion in the question about how to implement a fixed-length string in C#, and I provided a possible method (though I recommended against using fixed-length strings in any form). However, one of the answers mentioned VBFixedStringAttribute, without further explanation and I was intrigued to find out what that was about. However, when I went looking for some information on it, I could find very little on MSDN or even in a Bing search. The question then is “How does one actually use this?”

I could find no C# code examples, and though there was a mimimal example of VB.NET on MSDN, my VB.NET skills are insufficient to figure out what was going on with it so I could translate it to C#.

Can someone provide a little code and explanation of what is going on with VBFixedStringAttribute?

  • 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-11T20:45:54+00:00Added an answer on June 11, 2026 at 8:45 pm

    I think the important thing to notice from the link VBFixedStringAttribute Class is

    The VBFixedStringAttribute is informational and cannot be used to convert a variable length string to a fixed string. The purpose of this attribute is to modify how strings in structures and non-local variables are used by methods or API calls that recognize the VBFixedStringAttribute. Keep in mind that this attribute does not change the actual length of the string itself.

    From VB.Net to C#

    Structure Person
        Public ID As Integer 
        Public MonthlySalary As Decimal 
        Public LastReviewDate As Long
        <VBFixedString(15)> Public FirstName As String
        <VBFixedString(15)> Public LastName As String
        <VBFixedString(15)> Public Title As String
        <VBFixedString(150)> Public ReviewComments As String 
    End Structure
    

    is the same as

    using Microsoft.VisualBasic;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    struct Person
    {
        public int ID;
        public decimal MonthlySalary;
        public long LastReviewDate;
        [VBFixedString(15)]
        public string FirstName;
        [VBFixedString(15)]
        public string LastName;
        [VBFixedString(15)]
        public string Title;
        [VBFixedString(150)]
        public string ReviewComments;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is very similar to another recent question: How can I return the current
In a recent question I asked I was directed to this website: http://developer.android.com/design/index.html Amazing
Searching around I haven't found any recent answers to this question. The other answers
There were some excellent answers to this question already, however, they are now outdated.
This is an extension of my recent question Avoiding race conditions in Python 3's
Referring on this question , I have a similar -but not the same- problem..
Consider this code: import logging print print logging.error(log) I get: print ERROR:root:log now if
Python imports. Again... I have this file structure: [test] start.py (from scripts import main)
The issue came up in this question , which I'll recapitulate in this code:
In this recent Stack Overflow question , the author wanted to change a list

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.