What is MIME type "text/x-vba"?

A MIME type is a string that tells browsers and other tools how to handle a particular kind of file.

text/x-vba is a MIME type for files containing Visual Basic code. It marks plain-text files so programs know to treat their contents as code that automates tasks or extends application functionality.
Files with the extension VB use this MIME type. They are common when writing macros for programs like those in the Microsoft Office suite.
Key details and uses:
For further reading on MIME types, visit this resource.

Associated file extensions

Usage Examples

HTTP Header

When serving content with this MIME type, set the Content-Type header:


    Content-Type: text/x-vba    
  

HTML

In HTML, you can specify the MIME type in various elements:


    <a href="file.dat" type="text/x-vba">Download file</a>    
  

Server-side (Node.js)

Setting the Content-Type header in Node.js:


    const http = require('http');    
    
    http.createServer((req, res) => {    
      res.setHeader('Content-Type', 'text/x-vba');    
      res.end('Content here');    
    }).listen(3000);    
  

Associated file extensions

FAQs

What is the primary use of the text/x-vba MIME type?

The text/x-vba MIME type is used to identify files containing Visual Basic source code, most commonly associated with the .vb extension. It tells web servers and applications that the file is plain text containing code, rather than a binary application or a generic text document.

How do I configure Apache to serve .vb files correctly?

To serve Visual Basic files with the correct MIME type on an Apache server, add the following line to your .htaccess file or main configuration: AddType text/x-vba .vb. This ensures that browsers and development tools recognize the content type properly.

Why does my browser download .vb files instead of displaying them?

Most web browsers do not have built-in engines to render or execute Visual Basic code, so they treat text/x-vba as a downloadable file for security reasons. If you want the code to display as text in the browser, you might need to configure the server to send the file as text/plain instead.

Is text/x-vba a standard IANA MIME type?

No, the x- prefix indicates that text/x-vba is a non-standard or experimental subtype. While it is widely recognized by development tools and editors for syntax highlighting, it is not part of the official IANA registry.

How do I add text/x-vba support to IIS?

In Internet Information Services (IIS), unknown file extensions like .vb may be blocked by default. Open the MIME Types feature in IIS Manager, click Add, and enter .vb for the file extension and text/x-vba for the MIME type.

Are there security risks associated with text/x-vba files?

Yes, because these files contain executable programming code. While the text/x-vba type itself is just text, downloading and running unverified scripts can compromise your system; always open these files in a secure editor like Visual Studio Code to inspect them before execution.

What is the difference between text/x-vba and text/vbscript?

text/x-vba is typically used for Visual Basic (often .NET or VBA) source code, while text/vbscript is used specifically for VBScript (.vbs) files. Although the languages share syntax, VBScript was designed for web and lightweight scripting, whereas Visual Basic is for full application development.

General FAQ

What is a MIME type?

A MIME (Multipurpose Internet Mail Extensions) type is a standard that indicates the nature and format of a document, file, or assortment of bytes. MIME types are defined and standardized in IETF's RFC 6838.

MIME types are important because they help browsers and servers understand how to process a file. When a browser receives a file from a server, it uses the MIME type to determine how to display or handle the content, whether it's an image to display, a PDF to open in a viewer, or a video to play.

MIME types consist of a type and a subtype, separated by a slash (e.g., text/html, image/jpeg, application/pdf). Some MIME types also include optional parameters.

How do I find the MIME type for a file?

You can check the file extension or use a file identification tool such as file --mime-type on the command line. Many programming languages also provide libraries to detect MIME types.

Why are multiple MIME types listed for one extension?

Different applications and historical conventions may use alternative MIME identifiers for the same kind of file. Showing them all helps ensure compatibility across systems.