Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Rs Vb6parse
https://docs.rs/vb6parse/1.0.1/
Admin
Documentation for rs_vb6parse, a project for parsing Visual Basic 6 code.
Tokens:
8,207,881
Snippets:
78,459
Trust Score:
9.1
Update:
4 months ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Get File Size Source: https://docs.rs/vb6parse/1.0.1/vb6parse/syntax/library/functions/file/lof/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E A simple example demonstrating how to get the size of a binary file using the LOF function. ```vb6 Dim fileSize As Long fileSize = LOF(1) ``` -------------------------------- ### VB6 Weekday Function - ISO Week (Monday Start) Example Source: https://docs.rs/vb6parse/1.0.1/vb6parse/syntax/library/functions/datetime/weekday/index.html?search=u32+-%3E+bool Demonstrates how to use the Weekday function with 'vbMonday' to get the day of the week according to the ISO 8601 standard. ```vb Dim isoDayOfWeek As Integer isoDayOfWeek = Weekday(myDate, vbMonday) ' Returns 1 for Monday, 7 for Sunday ``` -------------------------------- ### GetAllSettings vs GetSetting Example Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/environment/getallsettings.rs.html Demonstrates how to retrieve all settings at once using GetAllSettings and a single setting using GetSetting. ```vb ' GetAllSettings - Retrieve all settings at once Dim allSettings As Variant allSettings = GetAllSettings("MyApp", "Config") ' GetSetting - Retrieve one setting at a time Dim value As String value = GetSetting("MyApp", "Config", "Theme", "Default") ``` -------------------------------- ### Example: Create a directory with a full path Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/statements/filesystem/mkdir.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to create a directory using its complete, absolute path, including the drive letter and subdirectories. ```vb ' Create a directory with full path MkDir "C:\Program Files\MyApp" ``` -------------------------------- ### Getting Form Name Source: https://docs.rs/vb6parse/1.0.1/vb6parse/language/enum.FormRoot.html?search= Example of getting the form name from a FormRoot instance. ```rust use vb6parse::language::{FormRoot, Form}; use vb6parse::language::FormProperties; let form = Form { name: "MainForm".to_string(), tag: String::new(), index: 0, properties: FormProperties::default(), controls: Vec::new(), menus: Vec::new(), }; let root = FormRoot::Form(form); assert_eq!(root.name(), "MainForm"); ``` -------------------------------- ### Get Start of Current Line Offset Source: https://docs.rs/vb6parse/1.0.1/vb6parse/io/source_stream/struct.SourceStream.html?search= Returns the starting offset of the current line in the SourceStream. ```rust pub fn start_of_line(&self) -> usize ``` -------------------------------- ### GetSetting Basic Usage Examples Source: https://docs.rs/vb6parse/1.0.1/vb6parse/syntax/library/functions/environment/getsetting/index.html?search= Demonstrates how to retrieve various application settings using the GetSetting function, including examples with and without default values. ```vb6 Dim userName As String userName = GetSetting("MyApp", "User", "Name", "Guest") ``` ```vb6 Dim formLeft As String formLeft = GetSetting("MyApp", "Window", "Left", "0") ``` ```vb6 Dim lastFile As String lastFile = GetSetting("MyApp", "Recent", "File1") ``` ```vb6 Dim connString As String connString = GetSetting("MyApp", "Database", "ConnectionString", "") ``` -------------------------------- ### Get Fiscal Year Start Date Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/datetime/dateserial.rs.html?search=u32+-%3E+bool Calculates the start date of a fiscal year based on the calendar year and the starting month of the fiscal year. ```vb Function GetFiscalYearStart(calendarYear As Integer, fiscalStartMonth As Integer) As Date GetFiscalYearStart = DateSerial(calendarYear, fiscalStartMonth, 1) End Function ``` -------------------------------- ### Example: Create directory on a network drive Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/statements/filesystem/mkdir.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to create a directory on a shared network location using a UNC path. ```vb ' Create directory on network drive MkDir "\\Server\Share\NewFolder" ``` -------------------------------- ### Example 2: Getting First Characters Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/string/left_dollar.rs.html?search=std%3A%3Avec Illustrates how to get the first 5 characters from a given string. ```vb6 Dim text As String text = "Hello, World!" greeting = Left$(text, 5) ' "Hello" ``` -------------------------------- ### Example: Creating a VB6 Form Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/language/controls/form_root.rs.html?search=u32+-%3E+bool Demonstrates how to create and initialize a `Form` instance. This example shows setting the form's name and asserting its initial state. ```rust use vb6parse::language::{Form, FormProperties}; let form = Form { name: "MainForm".to_string(), tag: String::new(), index: 0, properties: FormProperties::default(), controls: Vec::new(), menus: Vec::new(), }; assert_eq!(form.name, "MainForm"); assert_eq!(form.controls.len(), 0); ``` -------------------------------- ### Example: Create nested directories Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/statements/filesystem/mkdir.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates creating a hierarchy of directories, emphasizing that parent directories must exist first. ```vb ' Create nested directories (parent must exist first) MkDir "C:\Temp" MkDir "C:\Temp\Logs" MkDir "C:\Temp\Logs\Archive" ``` -------------------------------- ### VB6 Example: Get Current Hour Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/datetime/hour.rs.html Demonstrates how to get the current hour of the day using the Hour function with Now. ```vb ' Example 1: Get current hour Dim currentHour As Integer currentHour = Hour(Now) Debug.Print "Current hour: " & currentHour ``` -------------------------------- ### Basic Examples Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/graphics/partition.rs.html?search=u32+-%3E+bool Illustrates how to use the Partition function for simple range checks and data grouping. ```APIDOC ## Basic Examples ### Example 1: Simple Partition ```vb Dim range As String range = Partition(15, 0, 100, 10) ' Returns " 10: 19" range = Partition(5, 0, 100, 10) ' Returns " 0: 9" range = Partition(95, 0, 100, 10) ' Returns " 90: 99" ``` ### Example 2: Frequency Distribution ```vb ' Count how many values fall in each range Dim values(100) As Integer Dim frequency As Collection Dim i As Integer Dim range As String Set frequency = New Collection ' Populate with sample data For i = 0 To 100 values(i) = Int(Rnd * 100) Next i ' Count frequencies For i = 0 To 100 range = Partition(values(i), 0, 99, 10) ' Increment count for this range Next i ``` ### Example 3: Age Grouping ```vb Function GetAgeGroup(age As Integer) As String ' Group ages into decades GetAgeGroup = Partition(age, 0, 100, 10) End Function ' Usage Debug.Print GetAgeGroup(25) ' Returns " 20: 29" Debug.Print GetAgeGroup(5) ' Returns " 0: 9" ``` ### Example 4: Out of Range Values ```vb Dim range As String range = Partition(-5, 0, 100, 10) ' Returns " : -1" (below start) range = Partition(150, 0, 100, 10) ' Returns "101: " (above stop) ``` ``` -------------------------------- ### Handle Start Mode Property Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/files/project/mod.rs.html?search= Parses and updates the start mode property for a VB6 project. It uses `parse_converted_value` to get the start mode value and assigns it to `project.properties.start_mode`. ```rust fn handle_start_mode<'a>( ctx: &mut ParserContext<'a>, input: &mut SourceStream<'a>, project: &mut ProjectFile<'a>, property_name: &'a str, ) { if let Some(start_mode_value) = parse_converted_value(ctx, input, property_name) { project.properties.start_mode = start_mode_value; } } ``` -------------------------------- ### Rust TokenStream Initialization and Navigation Example Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/lexer/token_stream.rs.html Demonstrates how to create a new TokenStream, check the current token, advance the stream, and backtrack to a previous token. ```rust use vb6parse::language::Token; use vb6parse::lexer::TokenStream; let tokens = vec![("Dim", Token::DimKeyword), (" ", Token::Whitespace), ("x", Token::Identifier)]; let mut stream = TokenStream::new("test.bas".to_string(), tokens); assert_eq!(stream.current(), Some(&("Dim", Token::DimKeyword))); stream.advance(); assert_eq!(stream.current(), Some(&(" ", Token::Whitespace))); stream.backtrack(); assert_eq!(stream.current(), Some(&("Dim", Token::DimKeyword))); ``` -------------------------------- ### Load and Apply Settings Source: https://docs.rs/vb6parse/1.0.1/vb6parse/syntax/library/functions/environment/getallsettings/index.html?search= Illustrates loading settings from a section and then applying them based on the setting key. This example shows applying theme and language settings. ```vb6 ' Load and apply settings Dim appSettings As Variant appSettings = GetAllSettings("MyApp", "Options") If Not IsEmpty(appSettings) Then Dim j As Long For j = 0 To UBound(appSettings, 1) Select Case appSettings(j, 0) Case "Theme" ApplyTheme appSettings(j, 1) Case "Language" SetLanguage appSettings(j, 1) End Select Next j End If ``` -------------------------------- ### VB6 ChrB$ Basic Example: Get Character from Code Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/string/chrb_dollar.rs.html?search=u32+-%3E+bool Demonstrates how to get a character from its ANSI code using ChrB$. ```vb ' Example 1: Get character from code Dim ch As String ch = ChrB$(65) ' Returns "A" ``` -------------------------------- ### VB6 CurDir$ Example: Get Current Directory Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/file/curdir_dollar.rs.html?search=std%3A%3Avec Demonstrates how to get the current directory of the default drive using CurDir$(). ```vb Dim currentDir As String currentDir = CurDir$() ``` -------------------------------- ### Example: Create a directory in the current directory Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/statements/filesystem/mkdir.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates creating a new folder within the current working directory. ```vb ' Create a directory in the current directory MkDir "MyNewFolder" ``` -------------------------------- ### VB6 Example: Get Current Year Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/datetime/year.rs.html Demonstrates how to get the current year using the Year function and the Date keyword. ```vb6 Sub ShowCurrentYear() Dim currentYear As Integer currentYear = Year(Date) MsgBox "Current year: " & currentYear End Sub ``` -------------------------------- ### Basic Picture Loading Examples Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/resources/loadrespicture.rs.html Demonstrates loading bitmap and icon resources using numeric IDs, and a bitmap using a string name. ```vb ' Load bitmap from resources Picture1.Picture = LoadResPicture(101, vbResBitmap) ' Load icon Image1.Picture = LoadResPicture(102, vbResIcon) ' Load using string name Picture2.Picture = LoadResPicture("SPLASH", vbResBitmap) ``` -------------------------------- ### VB6 Basic Example: Simple File Opener Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/interaction/command_dollar.rs.html A simple example of using Command$() to get a filename from the command line and open it. ```vb ' Example 3: Simple file opener Sub Main() Dim filename As String filename = Trim$(Command$()) If filename <> "" Then OpenFile filename End If End Sub ``` -------------------------------- ### Example: Creating and Using PropertyGroup Source: https://docs.rs/vb6parse/1.0.1/vb6parse/files/common/properties/struct.PropertyGroup.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to create a PropertyGroup instance with properties and assert its values. This example shows the typical usage pattern for initializing and verifying a PropertyGroup. ```rust use vb6parse::files::common::PropertyGroup; use vb6parse::language::Color; use vb6parse::language::color::VB_RED; use std::collections::HashMap; use either::Either; use uuid::Uuid; let mut properties = HashMap::new(); properties.insert("BackColor".to_string(), Either::Left(VB_RED.to_vb_string())); let group = PropertyGroup { name: "FormProperties".to_string(), guid: Some(Uuid::parse_str("123e4567-e89b-12d3-a456-426614174000")?), properties, }; assert_eq!(group.name, "FormProperties"); assert_eq!(group.guid.expect("Expected GUID").to_string(), "123e4567-e89b-12d3-a456-426614174000"); assert_eq!(group.properties.get("BackColor").expect("Expected 'BackColor'property"), &Either::Left(VB_RED.to_vb_string())); ``` -------------------------------- ### Example: Creating and Using PropertyGroup Source: https://docs.rs/vb6parse/1.0.1/vb6parse/files/common/properties/struct.PropertyGroup.html?search=std%3A%3Avec Demonstrates how to create a PropertyGroup instance, populate it with properties (including a color value), and assert its contents. This example requires importing necessary types from vb6parse and standard libraries. ```rust use vb6parse::files::common::PropertyGroup; use vb6parse::language::Color; use vb6parse::language::color::VB_RED; use std::collections::HashMap; use either::Either; use uuid::Uuid; let mut properties = HashMap::new(); properties.insert("BackColor".to_string(), Either::Left(VB_RED.to_vb_string())); let group = PropertyGroup { name: "FormProperties".to_string(), guid: Some(Uuid::parse_str("123e4567-e89b-12d3-a456-426614174000")?), properties, }; assert_eq!(group.name, "FormProperties"); assert_eq!(group.guid.expect("Expected GUID").to_string(), "123e4567-e89b-12d3-a456-426614174000"); assert_eq!(group.properties.get("BackColor").expect("Expected 'BackColor'property"), &Either::Left(VB_RED.to_vb_string())); ``` -------------------------------- ### VB6 ChrW$ Basic Example: Get Character from Code Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/string/chrw_dollar.rs.html Demonstrates how to get a character from its Unicode code point using ChrW$. ```vb ' Example 1: Get character from code Dim ch As String ch = ChrW$(65) ' Returns "A" ``` -------------------------------- ### VB6 File Monitoring Example Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/file/seek.rs.html This snippet demonstrates how to start monitoring a file, including setting the initial position and start time. ```vb Public Sub StartMonitoring(FileNum As Integer) m_FileNum = FileNum m_StartPosition = Seek(FileNum) m_StartTime = Timer m_FileSize = LOF(FileNum) End Sub ``` -------------------------------- ### Example: Create a directory on another drive Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/statements/filesystem/mkdir.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Illustrates creating a directory on a different disk drive than the current one. ```vb ' Create a directory on another drive MkDir "D:\Data\Reports" ``` -------------------------------- ### VB6 MkDir Statement Examples Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/statements/filesystem/mkdir.rs.html Demonstrates various ways to use the MkDir statement to create directories. Includes examples for creating directories in the current directory, with full paths, on different drives, nested directories, and on network drives. ```vb MkDir "MyNewFolder" ``` ```vb MkDir "C:\Program Files\MyApp" ``` ```vb MkDir "D:\Data\Reports" ``` ```vb MkDir "C:\Temp" MkDir "C:\Temp\Logs" MkDir "C:\Temp\Logs\Archive" ``` ```vb MkDir "\\Server\Share\NewFolder" ``` -------------------------------- ### VB6 Get Current Date and Time Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/datetime/now.rs.html Example of how to get the current date and time using the Now function and store it in a Date variable. ```vb ' Example 1: Get current date and time Dim currentDateTime As Date currentDateTime = Now ``` -------------------------------- ### VB6 Get Current Date as String Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/datetime/date_dollar.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Example of how to get the current system date and store it in a String variable using Date$. ```vb Dim dateStr As String dateStr = Date$ ``` -------------------------------- ### VB6 GetSetting Functions Example Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/arrays/split.rs.html?search=std%3A%3Avec Provides functions to retrieve settings from a loaded configuration. Includes retrieval of string, integer (with numeric check), and delimited list values. ```vb6 Public Function GetSetting(key As String, Optional defaultValue As String = "") As String If m_settings.Exists(key) Then GetSetting = m_settings(key) Else GetSetting = defaultValue End If End Function Public Function GetSettingAsInteger(key As String, Optional defaultValue As Integer = 0) As Integer If m_settings.Exists(key) Then If IsNumeric(m_settings(key)) Then GetSettingAsInteger = CInt(m_settings(key)) Else GetSettingAsInteger = defaultValue End If Else GetSettingAsInteger = defaultValue End If End Function Public Function GetSettingList(key As String, delimiter As String) As String() If m_settings.Exists(key) Then GetSettingList = Split(m_settings(key), delimiter) Else Dim empty() As String ReDim empty(0 To -1) GetSettingList = empty End If End Function ``` -------------------------------- ### VB6 Example: Combine WeekdayName with Weekday Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/datetime/weekdayname.rs.html?search=u32+-%3E+bool Example showing how to get the localized name of today's day by combining WeekdayName and Weekday. ```vb6 ' Get the name of today's day dayName = WeekdayName(Weekday(Date)) ``` -------------------------------- ### VB6 GetSetting Comparison Example Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/environment/getsetting.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates comparing the result of GetSetting with an empty string to conditionally execute code. ```vb6 Sub Test() If Len(GetSetting("MyApp", "User", "Name", "")) = 0 Then ShowWelcome End If End Sub ``` -------------------------------- ### VB6 Partition Function - Simple Examples Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/graphics/partition.rs.html?search= Demonstrates basic usage of the Partition function to categorize numbers within a range. ```vb Dim range As String range = Partition(15, 0, 100, 10) ' Returns " 10: 19" range = Partition(5, 0, 100, 10) ' Returns " 0: 9" range = Partition(95, 0, 100, 10) ' Returns " 90: 99" ``` -------------------------------- ### Extracting GUID Components with MidB$ Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/string/midb_dollar.rs.html?search= Example of using MidB$ to extract byte segments that correspond to parts of a GUID (Globally Unique Identifier). ```vb6 Dim guidBytes As String guidBytes = GetGUID() data1 = MidB$(guidBytes, 1, 4) ' First DWORD data2 = MidB$(guidBytes, 5, 2) ' First WORD data3 = MidB$(guidBytes, 7, 2) ' Second WORD ``` -------------------------------- ### VB6 GetSetting Basic Usage Examples Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/environment/getsetting.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to use the GetSetting function to retrieve various types of application settings, including those with and without default values. ```vb ' Example 1: Get a simple setting with default Dim userName As String userName = GetSetting("MyApp", "User", "Name", "Guest") ``` ```vb ' Example 2: Get window position Dim formLeft As String formLeft = GetSetting("MyApp", "Window", "Left", "0") ``` ```vb ' Example 3: Get setting without default Dim lastFile As String lastFile = GetSetting("MyApp", "Recent", "File1") ``` ```vb ' Example 4: Get database connection Dim connString As String connString = GetSetting("MyApp", "Database", "ConnectionString", "") ``` -------------------------------- ### VB6 InStrRev Example 4: Search with Start Position Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/string/instrrev.rs.html?search= Demonstrates using the optional 'start' parameter in InStrRev to specify the search position. ```vb Dim text As String Dim pos As Long text = "one,two,three,four" pos = InStrRev(text, ",", 10) ' Search up to position 10 Debug.Print pos ' Prints: 8 (comma after "two") ``` -------------------------------- ### Example: Creating an MDI Form Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/language/controls/form_root.rs.html?search=u32+-%3E+bool Illustrates the creation of an `MDIForm` instance. This example sets the MDI form's name and verifies its initial control count. ```rust use vb6parse::language::{MDIForm, MDIFormProperties}; let mdi_form = MDIForm { name: "MDIMain".to_string(), tag: String::new(), index: 0, properties: MDIFormProperties::default(), controls: Vec::new(), menus: Vec::new(), }; assert_eq!(mdi_form.name, "MDIMain"); assert_eq!(mdi_form.controls.len(), 0); ``` -------------------------------- ### VB6 InputBox Basic Usage: Get User Name Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/interaction/inputbox.rs.html?search= A simple example demonstrating how to get user input for a name and display a greeting. ```vb ' Example 1: Simple input Dim userName As String userName = InputBox("Enter your name:") If userName <> "" Then MsgBox "Hello, " & userName End If ``` -------------------------------- ### VB6 Replace Function with Start and Count Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/string/replace.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to use both 'start' and 'count' parameters in the VB6 Replace function. This example starts searching from the 10th character and replaces only the first occurrence found after that position. ```vb Dim originalString As String Dim newString As String originalString = "This is an old string with old words." newString = Replace(originalString, "old", "new", 10, 1) ' newString will be "This is an old string with new words." ``` -------------------------------- ### Loading and Writing Binary Data to File Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/resources/loadresdata.rs.html This example demonstrates loading binary data from a resource using its numeric ID and then writing that data to a file. ```vb ' Load binary data from resource Dim resourceData() As Byte resourceData = LoadResData(101, 256) ' Use the data Dim fileNum As Integer fileNum = FreeFile Open "C:\output.dat" For Binary As #fileNum Put #fileNum, , resourceData Close #fileNum ``` -------------------------------- ### VB6 Basic Example: Get Command Line Arguments Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/interaction/command_dollar.rs.html Demonstrates how to retrieve and display the command-line arguments using Command$(). ```vb ' Example 1: Get command line arguments Sub Main() Dim cmdLine As String cmdLine = Command$() MsgBox "Arguments: " & cmdLine End Sub ``` -------------------------------- ### Get Start of Current Line Offset Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/io/source_stream.rs.html Calculates and returns the starting offset of the line that the current `offset` is on. It searches backward for the preceding newline character. ```rust pub fn start_of_line(&self) -> usize { self.start_of_line_from(self.offset) } ``` -------------------------------- ### VB6 MonthName Example: Get Full Month Name Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/datetime/monthname.rs.html Demonstrates how to get the full name of a month using the MonthName function with a month number. ```vb ' Example 1: Get full month name Dim monthName As String monthName = MonthName(3) ' Returns "March" ``` -------------------------------- ### VB.NET MkDir Statement Examples Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/statements/filesystem/mkdir.rs.html?search= Demonstrates various ways to use the MkDir statement, including creating directories in the current directory, with full paths, on different drives, and creating nested directories. ```vb ' Create a directory in the current directory MkDir "MyNewFolder" ``` ```vb ' Create a directory with full path MkDir "C:\Program Files\MyApp" ``` ```vb ' Create a directory on another drive MkDir "D:\Data\Reports" ``` ```vb ' Create nested directories (parent must exist first) MkDir "C:\Temp" MkDir "C:\Temp\Logs" MkDir "C:\Temp\Logs\Archive" ``` ```vb ' Create directory on network drive MkDir "\\Server\Share\NewFolder" ``` -------------------------------- ### VB6 Get Statement Usage Example Source: https://docs.rs/vb6parse/1.0.1/vb6parse/syntax/library/functions/interaction/input/index.html?search= Demonstrates the Get statement for reading binary data directly into variables. This is typically used with files opened in Binary mode. ```vb6 Get #1, , myVar ``` -------------------------------- ### Example Project File Parsing Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/files/project/mod.rs.html Demonstrates how to decode a VB6 project source file string into a `SourceFile` object. Handles potential decoding errors. ```Rust let input = r#"Type=Exe Reference=* Object={00020430-0000-0000-C000-000000000046}#2.0#0; stdole2.tlb Module=Module1; Module1.bas Class=Class1; Class1.cls "#; let project_source_file = match SourceFile::decode_with_replacement("project1.vbp", input.as_bytes()) { Ok(source_file) => source_file, Err(e) => { e.print(); panic!("failed to decode project source code."); } }; ``` -------------------------------- ### VB6 Get Statement Examples Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/statements/file_operations/get.rs.html?search=std%3A%3Avec Demonstrates various ways to use the Get statement in VB6, including specifying file number, record number, and variable name. ```vb Get #1, , myRecord ``` ```vb Get #1, recordNumber, customerData ``` ```vb Get fileNum, , buffer ``` -------------------------------- ### GetAllSettings vs File-Based Storage Example Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/environment/getallsettings.rs.html Compares using GetAllSettings with the Windows registry versus file-based storage like INI or XML files. ```vb ' GetAllSettings - Windows registry settings = GetAllSettings(App.Title, "Settings") ' File-based - INI file or XML (more portable) ' Requires custom parsing code ``` -------------------------------- ### SaveSetting Simple Example Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/statements/system_interaction/savesetting.rs.html?search= Demonstrates parsing a basic SaveSetting statement with literal values for application, section, key, and value. ```vb Sub Test() SaveSetting "MyApp", "Startup", "Left", 100 End Sub ``` -------------------------------- ### MidB Example: Start Position Beyond Length Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/string/midb.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Illustrates the behavior of MidB when the specified start position is greater than the string's length, resulting in an empty string. ```vb result = MidB("Hi", 10) ' Returns "" ``` -------------------------------- ### VB6 GetSetting Error Handling Example Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/environment/getsetting.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to implement error handling with On Error Resume Next when using GetSetting to gracefully manage potential errors. ```vb6 Sub Test() On Error Resume Next value = GetSetting("MyApp", "Config", "Setting", "Default") If Err.Number <> 0 Then Err.Clear On Error GoTo 0 End Sub ``` -------------------------------- ### Fiscal Year Calculations Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/datetime/dateserial.rs.html?search= Provides functions to determine the start and end dates of a fiscal year, and to get the current fiscal year based on a specified fiscal start month. Assumes the fiscal year starts on the 1st of the specified month. ```vb Function GetFiscalYearStart(calendarYear As Integer, fiscalStartMonth As Integer) As Date GetFiscalYearStart = DateSerial(calendarYear, fiscalStartMonth, 1) End Function Function GetFiscalYearEnd(calendarYear As Integer, fiscalStartMonth As Integer) As Date ' Fiscal year end is day before next fiscal year starts GetFiscalYearEnd = DateSerial(calendarYear + 1, fiscalStartMonth, 0) End Function Function GetCurrentFiscalYear(fiscalStartMonth As Integer) As Integer Dim currentMonth As Integer currentMonth = Month(Date) If currentMonth >= fiscalStartMonth Then GetCurrentFiscalYear = Year(Date) Else GetCurrentFiscalYear = Year(Date) - 1 End If End Function ``` -------------------------------- ### Form Initialization Example Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/resources/loadrespicture.rs.html Loads a form's background bitmap and several toolbar icon resources during the Form_Load event. ```vb Private Sub Form_Load() ' Load form background Me.Picture = LoadResPicture(101, vbResBitmap) ' Load toolbar icons cmdNew.Picture = LoadResPicture(201, vbResIcon) cmdOpen.Picture = LoadResPicture(202, vbResIcon) cmdSave.Picture = LoadResPicture(203, vbResIcon) End Sub ``` -------------------------------- ### Get Start of Current Line Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/io/source_stream.rs.html?search= Calculates and returns the starting offset of the line that the current `offset` is on. If the current offset is at the beginning of the file and no preceding newline exists, it returns 0. ```Rust pub fn start_of_line(&self) -> usize { self.start_of_line_from(self.offset) } ``` -------------------------------- ### Get Start of Line from Offset Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/io/source_stream.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Finds the starting offset of the line that contains a given offset within the source stream. It searches backward from the specified offset for a newline character. ```rust pub fn start_of_line_from(&self, offset: usize) -> usize { // Find the last newline character before the current offset if let Some(pos) = self.contents[..offset].rfind(' ') { pos + 1 // Return the position after the newline character } else { 0 // If no newline found, return the start of the stream } } ``` -------------------------------- ### VB6 Example: Get Command Line Arguments Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/interaction/command_dollar.rs.html?search=u32+-%3E+bool Demonstrates how to retrieve and display the command-line arguments using the Command$ function. ```vb Sub Main() Dim cmdLine As String cmdLine = Command$() MsgBox "Arguments: " & cmdLine End Sub ``` -------------------------------- ### VB6 CurDir$ Example: Getting Directory for Specific Drives Source: https://docs.rs/vb6parse/1.0.1/src/vb6parse/syntax/library/functions/file/curdir_dollar.rs.html Illustrates how to get the current directory for specific drives (e.g., 'C' and 'D') by passing the drive letter to CurDir$(). ```vb6 Sub Main() Dim c As String, d As String c = CurDir$("C") d = CurDir$("D") End Sub ```