I'm using Visual Basic to read a file which has frequently-used information. Specifically, my file contains information like this:
[Smith]
Name=Sam Smith
Email=sam.smith#yahoo.com
Project=Smith's Treehouse Project
Greeting=Hi Sam,
[Jones]
Name=Josh Jones
Email=josh.jones#gmail.com
Project=Jone's Second-Story Remodel
Greeting=Hi Josh,
I'm then trying to read the info into a simple VB command (actually using Dragon Naturally Speaking, but that shouldn't matter) to send an email in Microsoft Outlook. I don't need to write to the file, or change the values. I just need to read the info, so I can send the email address to the address field, the project name to the subject field, etc. through the use of List Variables.
How do I write a function to read from the file?
I've spent about 4 hours looking for answers here and on other sites, but am confused. (I'm obviously brand new to VB.) It seems like every time I find code that looks kind of close, it uses unique coding functions, so I don't know what the right one is.
Any help appreciated!
Perhaps not the most elegant solution, but here's a class that utilizes Regular Expressions to parse the INI:
Imports System.IO
Imports System.Text.RegularExpressions
Public NotInheritable Class IniParser
Private Shared SectionRegex As New Regex("\[(?<section>[^\n\[\]]+)\]\n*(?<valuelist>(.(?!\[[^\n\[\]]+\]))*)", RegexOptions.Singleline Or RegexOptions.CultureInvariant Or RegexOptions.Compiled)
Private Shared ValueRegex As New Regex("(?<valuename>[^=\n]+)=(?<value>[^\n]*)", RegexOptions.CultureInvariant Or RegexOptions.Compiled)
''' <summary>
''' Parses an .ini-file.
''' </summary>
''' <param name="FileName">The path to the file to parse.</param>
''' <remarks></remarks>
Public Shared Function ParseFile(ByVal FileName As String) As Dictionary(Of String, Dictionary(Of String, String))
Return IniParser.Parse(File.ReadAllText(FileName))
End Function
''' <summary>
''' Parses a text of .ini-format.
''' </summary>
''' <param name="Data">The text to parse.</param>
''' <remarks></remarks>
Public Shared Function Parse(ByVal Data As String) As Dictionary(Of String, Dictionary(Of String, String))
Dim Result As New Dictionary(Of String, Dictionary(Of String, String)) '(Section, (Value name, Value))
Dim Sections As MatchCollection = SectionRegex.Matches(Data)
'Iterate each section.
For Each SectionMatch As Match In Sections
Dim Section As New Dictionary(Of String, String)
Dim SectionName As String = SectionMatch.Groups("section").Value
Dim Values As MatchCollection = ValueRegex.Matches(SectionMatch.Groups("valuelist").Value)
If Result.ContainsKey(SectionName) = True Then
'A section by this name already exists.
Dim i As Integer = 1
'Append a number to the section name until a unique name is found.
While Result.ContainsKey(SectionName & i)
i += 1
End While
Result.Add(SectionName & i, Section)
Else
'A section by this name does not exist.
Result.Add(SectionName, Section)
End If
'Iterate each value of this section.
For Each ValueMatch As Match In Values
Dim ValueName As String = ValueMatch.Groups("valuename").Value
Dim Value As String = ValueMatch.Groups("value").Value
If Section.ContainsKey(ValueName) = True Then
'A value by this name already exists.
Dim i As Integer = 1
'Append a number to the value name until a unique name is found.
While Section.ContainsKey(ValueName & i)
i += 1
End While
Section.Add(ValueName & i, Value)
Else
'A value by this name does not exist.
Section.Add(ValueName, Value)
End If
Next
Next
Return Result
End Function
End Class
Example usage
Reading values in general:
Dim IniContents As Dictionary(Of String, Dictionary(Of String, String)) = IniParser.ParseFile("C:\path\to\your\file\here.ini")
For Each SectionName As String In IniContents.Keys
For Each ValueName As String In IniContents(SectionName).Keys
Dim Value As String = IniContents(SectionName)(ValueName)
'[SectionName]
'ValueName=Value
'ValueName=Value
'
'SectionName: The name of the current section (ex: Jones).
'ValueName : The name of the current value (ex: Email).
'Value : The value of [ValueName] (ex: josh.jones#gmail.com).
Console.WriteLine(SectionName & ": " & ValueName & " = " & Value)
Next
Next
Adding everything to a TreeView, where the node's Tag property is the value:
Dim IniContents As Dictionary(Of String, Dictionary(Of String, String)) = IniParser.ParseFile("C:\path\to\your\file\here.ini")
For Each SectionName As String In IniContents.Keys
Dim TopNode As TreeNode = TreeView1.Nodes.Add(SectionName)
Dim Section As Dictionary(Of String, String) = IniContents(SectionName)
For Each ValueName As String In Section.Keys
TopNode.Nodes.Add(New TreeNode(ValueName) With {.Tag = Section(ValueName)})
Next
Next
Screenshot of the TreeView example
Regex pattern explanation
SectionRegex:
\[(?<section>[^\n\[\]]+)\]\n*(?<valuelist>(.(?!\[[^\n\[\]]+\]))*)
\[ => Match '['.
(?<section> => Start of match group "section".
[^ => Match any character...
\n\[\] => ...that is not '[', ']' or a new line...
]+ => ...and match this one or more times.
) => End of match group "section".
\] => Match ']'.
\n* => Match zero or more new lines
(?<valuelist> => Start of match group "valuelist".
( => Start of unnamed match group.
. => Match any character...
(?! => ...that is not followed by...
\[[^\n\[\]]+\] => ...a section...
)
)* => ...and match this zero or more times.
) => End of match group "valuelist".
ValueRegex:
(?<valuename>[^=\n]+)=(?<value>[^\n]*)
(?<valuename> => Start of match group "valuename".
[^=\n]+ => Match one or more characters that are not '=' or a new line.
) => End of match group "valuename".
= => Match '='.
(?<value> => Start of match group "value".
[^\n]* => Match zero or more characters that are not a new line.
) => End of match group "value".
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a() As String = IO.File.ReadAllLines(iniPath)
Dim user As String = "Jones"
Dim data As String = "Project"
For i = 0 To UBound(a)
If a(i) = "[" + user + "]" Then
For j = i To 1000
If a(j).Contains(data) Then TextBox1.Text = a(j).Replace(data + "=", "") : Exit For
Next
Exit for
End If
Next
End Sub
Related
I would like to ask for your help regarding my problem. I want to create a module for my program where it would read .txt file, find a specific value and insert it to the text box.
As an example I have a text file called system.txt which contains single line text. The text is something like this:
[Name=John][Last Name=xxx_xxx][Address=xxxx][Age=22][Phone Number=8454845]
What i want to do is to get only the last name value "xxx_xxx" which every time can be different and insert it to my form's text box
Im totally new in programming, was looking for the other examples but couldnt find anything what would fit exactly to my situation.
Here is what i could write so far but i dont have any idea if there is any logic in my code:
Dim field As New List(Of String)
Private Sub readcrnFile()
For Each line In File.ReadAllLines(C:\test\test_1\db\update\network\system.txt)
For i = 1 To 3
If line.Contains("Last Name=" & i) Then
field.Add(line.Substring(line.IndexOf("=") + 2))
End If
Next
Next
End Sub
Im
You can get this down to a function with a single line of code:
Private Function readcrnFile(fileName As String) As IEnumerable(Of String)
Return File.ReadLines(fileName).Where(Function(line) RegEx.IsMatch(line, "[[[]Last Name=(?<LastName>[^]]+)]").Select(Function(line) RegEx.Match(line, exp).Groups("LastName").Value)
End Function
But for readability/maintainability and to avoid repeating the expression evaluation on each line I'd spread it out a bit:
Private Function readcrnFile(fileName As String) As IEnumerable(Of String)
Dim exp As New RegEx("[[[]Last Name=(?<LastName>[^]]+)]")
Return File.ReadLines(fileName).
Select(Function(line) exp.Match(line)).
Where(Function(m) m.Success).
Select(Function(m) m.Groups("LastName").Value)
End Function
See a simple example of the expression here:
https://dotnetfiddle.net/gJf3su
Dim strval As String = " [Name=John][Last Name=xxx_xxx][Address=xxxx][Age=22][Phone Number=8454845]"
Dim strline() As String = strval.Split(New String() {"[", "]"}, StringSplitOptions.RemoveEmptyEntries) _
.Where(Function(s) Not String.IsNullOrWhiteSpace(s)) _
.ToArray()
Dim lastnameArray() = strline(1).Split("=")
Dim lastname = lastnameArray(1).ToString()
Using your sample data...
I read the file and trim off the first and last bracket symbol. The small c following the the 2 strings tell the compiler that this is a Char. The braces enclosed an array of Char which is what the Trim method expects.
Next we split the file text into an array of strings with the .Split method. We need to use the overload that accepts a String. Although the docs show Split(String, StringSplitOptions), I could only get it to work with a string array with a single element. Split(String(), StringSplitOptions)
Then I looped through the string array called splits, checking for and element that starts with "Last Name=". As soon as we find it we return a substring that starts at position 10 (starts at zero).
If no match is found, an empty string is returned.
Private Function readcrnFile() As String
Dim LineInput = File.ReadAllText("system.txt").Trim({"["c, "]"c})
Dim splits = LineInput.Split({"]["}, StringSplitOptions.None)
For Each s In splits
If s.StartsWith("Last Name=") Then
Return s.Substring(10)
End If
Next
Return ""
End Function
Usage...
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
TextBox1.Text = readcrnFile()
End Sub
You can easily split that line in an array of strings using as separators the [ and ] brackets and removing any empty string from the result.
Dim input As String = "[Name=John][Last Name=xxx_xxx][Address=xxxx][Age=22][Phone Number=8454845]"
Dim parts = input.Split(New Char() {"["c, "]"c}, StringSplitOptions.RemoveEmptyEntries)
At this point you have an array of strings and you can loop over it to find the entry that starts with the last name key, when you find it you can split at the = character and get the second element of the array
For Each p As String In parts
If p.StartsWith("Last Name") Then
Dim data = p.Split("="c)
field.Add(data(1))
Exit For
End If
Next
Of course, if you are sure that the second entry in each line is the Last Name entry then you can remove the loop and go directly for the entry
Dim data = parts(1).Split("="c)
A more sophisticated way to remove the for each loop with a single line is using some of the IEnumerable extensions available in the Linq namespace.
So, for example, the loop above could be replaced with
field.Add((parts.FirstOrDefault(Function(x) x.StartsWith("Last Name"))).Split("="c)(1))
As you can see, it is a lot more obscure and probably not a good way to do it anyway because there is no check on the eventuality that if the Last Name key is missing in the input string
You should first know the difference between ReadAllLines() and ReadLines().
Then, here's an example using only two simple string manipulation functions, String.IndexOf() and String.Substring():
Sub Main(args As String())
Dim entryMarker As String = "[Last Name="
Dim closingMarker As String = "]"
Dim FileName As String = "C:\test\test_1\db\update\network\system.txt"
Dim value As String = readcrnFile(entryMarker, closingMarker, FileName)
If Not IsNothing(value) Then
Console.WriteLine("value = " & value)
Else
Console.WriteLine("Entry not found")
End If
Console.Write("Press Enter to Quit...")
Console.ReadKey()
End Sub
Private Function readcrnFile(ByVal entry As String, ByVal closingMarker As String, ByVal fileName As String) As String
Dim entryIndex As Integer
Dim closingIndex As Integer
For Each line In File.ReadLines(fileName)
entryIndex = line.IndexOf(entry) ' see if the marker is in our line
If entryIndex <> -1 Then
closingIndex = line.IndexOf(closingMarker, entryIndex + entry.Length) ' find first "]" AFTER our entry marker
If closingIndex <> -1 Then
' calculate the starting position and length of the value after the entry marker
Dim startAt As Integer = entryIndex + entry.Length
Dim length As Integer = closingIndex - startAt
Return line.Substring(startAt, length)
End If
End If
Next
Return Nothing
End Function
How can I remove my duplicates in the List(Of String)? I was under the assumption that it could work with List(Of T).Distinct, but my result says otherwise. What am I doing wrong? Or what do I have to change to remove the duplicate items in the List(Of T)?
I have read something on the worldwide web about hash something, but I don't think that is really necessary.
This is my code where the list is generated (works with Autodesk Inventor).
Private Function CountCylinders(ByVal oDef As AssemblyComponentDefinition) As Integer
' Lets list all cylinder segments found in the assembly
' we will need the document name to do this.
' the initial value is nothing, if, after counting
' this is still the case, there are no cylinders.
Dim oList As New List(Of String)
' Loop through all of the occurences found in the assembly
For Each oOccurrence As ComponentOccurrence In oDef.Occurrences
' Get the occurence document
Dim oOccurenceDocument As Document
oOccurenceDocument = oOccurrence.Definition.Document
' Check if the occurence document name contains cylinder
If oOccurenceDocument.FullFileName.Contains("Cylinder") Then
' Get the cylinder filename
Dim oCylinder As String
oCylinder = oOccurenceDocument.FullFileName
' Get the filename w/o extension
oCylinder = IO.Path.GetFileNameWithoutExtension(oCylinder)
' Remove the segment mark.
oCylinder = oCylinder.Remove(oCylinder.LastIndexOf("_"), oCylinder.Length - oCylinder.LastIndexOf("_"))
oList.Add(oCylinder)
Debug.Print("add : " & oCylinder)
End If
Next
' Delete the duplicates in the list
oList.Distinct()
' TODO: can be removed.
Debug.Print("Total number of cylinders = " & oList.Count)
' Return the number of cylinders
CountCylinders = oList.Count
End Function
Here is my debug output from the code:
add : Cylinder_1
add : Cylinder_2
add : Cylinder_2
add : Cylinder_2
add : Cylinder_2
add : Cylinder_2
add : Cylinder_7
Total number of cylinders = 7
This is the answer you're looking for thanks to dotnetperls.com VB.NET Remove Duplicates From List
ListOfString.Distinct().ToList
Imports System.Linq
...
Dim oList As New List(Of String)
oList.Add("My Cylinder")
oList = oList.Distinct.ToList()
It's necessary to include System.Linq.
Function RemoveDuplicate(ByVal TheList As List(Of String)) As List(Of String)
Dim Result As New List(Of String)
Dim Exist As Boolean = False
For Each ElementString As String In TheList
Exist = False
For Each ElementStringInResult As String In Result
If ElementString = ElementStringInResult Then
Exist = True
Exit For
End If
Next
If Not Exist Then
Result.Add(ElementString)
End If
Next
Return Result
End Function
I tried to create a unique code for each shop in the form I made. I have two TextBox controls (TBNameStore and TBCodeStore). What I want is that when I write the name of the shop, for example "Brothers in Arm", in TBNameStore, then TBCodeStore should automatically be filled with the text "BIA".
How can I do that?
Well I write a code that can help you with your problem.
Option Strict On
Public Class Form1
Public Function GetInitials(ByVal MyText As String) As String
Dim Initials As String = ""
Dim AllWords() As String = MyText.Split(" "c)
For Each Word As String In AllWords
If Word.Length > 0 Then
Initials = Initials & Word.Chars(0).ToString.ToUpper
End If
Next
Return Initials
End Function
Private Sub TBNameStore_TextChanged(sender As Object, e As EventArgs) Handles TBNameStore.TextChanged
TBCodeStore.Text = GetInitials(TBNameStore.Text)
End Sub
End Class
Like you can see, the GetInitials get you all the first letter of all the words in the text.
One possible solution using the mentioned Split and SubString methods and LINQ could look like this:
create a StringBuilder where every first character of each word is stored
separate the words using the specified delimiter (default is empty space) using the String.Split method
convert the array to list in order to apply the LINQ-ToList extension => ToList()
for each found word => ForEach(sub (word as String) ...
take the first character from the word, convert it to upper case and put it in the result
=> result.Append(word.SubString(0, 1).ToUpper())
return the result as string => result.ToString()
The code looks like this:
private function abbreviation(input as String, optional delimiter as String = " ")
dim result = new StringBuilder()
input.Split(delimiter) _
.ToList() _
.ForEach(sub (word as String)
result.Append(word.SubString(0, 1).ToUpper())
end sub)
return result.ToString()
end function
Usage:
dim s = "Brothers in Arms"
Console.WriteLine("{0} => {1}", s, abbreviation(s))
and the output looks like expected:
Brothers in Arms => BIA
I have an uploaded file, displaying
Han 33.3
Han 5.66
Han 8.3
Chewbacca 99.4
Chewbacca 100.3
Chewbacca 98.1
I need to make an average for each han and Chewbacca using a dictionary, but first I have to split the list in order to do that. How do I split them for this purpose.
I'm making the assumption that the whitespace between the name and quantity is a single space. I'm also calling your values "scores" and Han and Chewbacca "players" for my example solution. The result splits the line into individual key-value pairs; each key represents the list of values found; it:
Imports System.IO
Dim pathToYourFile As String = "Path to your file with file name"
Dim f As StreamReader = File.OpenText(pathToYourFile)
Dim fileText As String = f.ReadToEnd
f.Close()
Dim singleSpace As String = " " 'single space between quotes
Dim playerScores As New SortedDictionary(Of String, List(Of Double))
Dim lines() As String = fileText.Split(vbCrLf.ToCharArray())
For i As Integer = 0 To lines.Length - 1
Dim scoreLine() As String = lines(i).Split(" ".ToCharArray())
Dim playerName As String = scoreLine(0)
Dim score As Double = Double.Parse(scoreLine(1))
If playerScores.ContainsKey(playerName) Then
playerScores(playerName).Add(score)
Else
Dim list As New List(Of Double)
list.Add(score)
playerScores.Add(playerName, list)
End If
Next i
Try this:
Public Class DataClass
Public Property Name() As String
Public Property Value() As Decimal
End Class
' ...
Public Shared Function GetAverageDict(lines As IEnumerable(Of String)) _
As Dictionary(Of String, Decimal)
Dim lst As New List(Of DataClass)()
For Each line As String In lines
Dim lastSpaceIndex = line.LastIndexOf(" ")
If (lastSpaceIndex >= 0) Then
Dim name = line.Substring(0, lastSpaceIndex).Trim()
Dim value = Decimal.Parse(line.Substring(lastSpaceIndex + 1), _
System.Globalization.CultureInfo.InvariantCulture)
lst.Add(New DataClass() With { .Name = name, .Value = value })
End If
Next
Dim averages = From g In From x In lst _
Group x By key = x.Name _
Select New With { .Name = key, _
.Average = Group.Average(Function(y) y.Value) }
Return averages.ToDictionary(Function(x) x.Name, Function(y) y.Average)
End Function
The function first gets the parts from each line. It assumes that the last space is the separator between the parts. This way, the name can also contain space characters.
The data is collected in a list that is afterwards grouped by the name. By calling ToDictionary the result of the grouping operation is converted in a dictionary.
Call the function like this:
Dim dict = GetAverageDict(System.IO.File.GetLines(filePath))
How do i Declare a string like this:
Dim strBuff As String * 256
in VB.NET?
Use the VBFixedString attribute. See the MSDN info here
<VBFixedString(256)>Dim strBuff As String
It depends on what you intend to use the string for. If you are using it for file input and output, you might want to use a byte array to avoid encoding problems. In vb.net, A 256-character string may be more than 256 bytes.
Dim strBuff(256) as byte
You can use encoding to transfer from bytes to a string
Dim s As String
Dim b(256) As Byte
Dim enc As New System.Text.UTF8Encoding
...
s = enc.GetString(b)
You can assign 256 single-byte characters to a string if you need to use it to receive data, but the parameter passing may be different in vb.net than vb6.
s = New String(" ", 256)
Also, you can use vbFixedString. I'm not sure exactly what this does, however, because when you assign a string of different length to a variable declared this way, it becomes the new length.
<VBFixedString(6)> Public s As String
s = "1234567890" ' len(s) is now 10
To write this VB 6 code:
Dim strBuff As String * 256
In VB.Net you can use something like:
Dim strBuff(256) As Char
Use stringbuilder
'Declaration
Dim S As New System.Text.StringBuilder(256, 256)
'Adding text
S.append("abc")
'Reading text
S.tostring
Try this:
Dim strbuf As New String("A", 80)
Creates a 80 character string filled with "AAA...."'s
Here I read a 80 character string from a binary file:
FileGet(1,strbuf)
reads 80 characters into strbuf...
You can use Microsoft.VisualBasic.Compatibility:
Imports Microsoft.VisualBasic.Compatibility
Dim strBuff As New VB6.FixedLengthString(256)
But it's marked as obsolete and specifically not supported for 64-bit processes, so write your own that replicates the functionality, which is to truncate on setting long values and padding right with spaces for short values. It also sets an "uninitialised" value, like above, to nulls.
Sample code from LinqPad (which I can't get to allow Imports Microsoft.VisualBasic.Compatibility I think because it is marked obsolete, but I have no proof of that):
Imports Microsoft.VisualBasic.Compatibility
Dim U As New VB6.FixedLengthString(5)
Dim S As New VB6.FixedLengthString(5, "Test")
Dim L As New VB6.FixedLengthString(5, "Testing")
Dim p0 As Func(Of String, String) = Function(st) """" & st.Replace(ChrW(0), "\0") & """"
p0(U.Value).Dump()
p0(S.Value).Dump()
p0(L.Value).Dump()
U.Value = "Test"
p0(U.Value).Dump()
U.Value = "Testing"
p0(U.Value).Dump()
which has this output:
"\0\0\0\0\0"
"Test "
"Testi"
"Test "
"Testi"
This object can be defined as a structure with one constructor and two properties.
Public Structure FixedLengthString
Dim mValue As String
Dim mSize As Short
Public Sub New(Size As Integer)
mSize = Size
mValue = New String(" ", mSize)
End Sub
Public Property Value As String
Get
Value = mValue
End Get
Set(value As String)
If value.Length < mSize Then
mValue = value & New String(" ", mSize - value.Length)
Else
mValue = value.Substring(0, mSize)
End If
End Set
End Property
End Structure
https://jdiazo.wordpress.com/2012/01/12/getting-rid-of-vb6-compatibility-references/
Have you tried
Dim strBuff as String
Also see Working with Strings in .NET using VB.NET
This tutorial explains how to
represent strings in .NET using VB.NET
and how to work with them with the
help of .NET class library classes.
Dim a as string
a = ...
If a.length > theLength then
a = Mid(a, 1, theLength)
End If
This hasn't been fully tested, but here's a class to solve this problem:
''' <summary>
''' Represents a <see cref="String" /> with a minimum
''' and maximum length.
''' </summary>
Public Class BoundedString
Private mstrValue As String
''' <summary>
''' The contents of this <see cref="BoundedString" />
''' </summary>
Public Property Value() As String
Get
Return mstrValue
End Get
Set(value As String)
If value.Length < MinLength Then
Throw New ArgumentException(String.Format("Provided string {0} of length {1} contains less " &
"characters than the minimum allowed length {2}.",
value, value.Length, MinLength))
End If
If value.Length > MaxLength Then
Throw New ArgumentException(String.Format("Provided string {0} of length {1} contains more " &
"characters than the maximum allowed length {2}.",
value, value.Length, MaxLength))
End If
If Not AllowNull AndAlso value Is Nothing Then
Throw New ArgumentNullException(String.Format("Provided string {0} is null, and null values " &
"are not allowed.", value))
End If
mstrValue = value
End Set
End Property
Private mintMinLength As Integer
''' <summary>
''' The minimum number of characters in this <see cref="BoundedString" />.
''' </summary>
Public Property MinLength() As Integer
Get
Return mintMinLength
End Get
Private Set(value As Integer)
mintMinLength = value
End Set
End Property
Private mintMaxLength As Integer
''' <summary>
''' The maximum number of characters in this <see cref="BoundedString" />.
''' </summary>
Public Property MaxLength As Integer
Get
Return mintMaxLength
End Get
Private Set(value As Integer)
mintMaxLength = value
End Set
End Property
Private mblnAllowNull As Boolean
''' <summary>
''' Whether or not this <see cref="BoundedString" /> can represent a null value.
''' </summary>
Public Property AllowNull As Boolean
Get
Return mblnAllowNull
End Get
Private Set(value As Boolean)
mblnAllowNull = value
End Set
End Property
Public Sub New(ByVal strValue As String,
ByVal intMaxLength As Integer)
MinLength = 0
MaxLength = intMaxLength
AllowNull = False
Value = strValue
End Sub
Public Sub New(ByVal strValue As String,
ByVal intMinLength As Integer,
ByVal intMaxLength As Integer)
MinLength = intMinLength
MaxLength = intMaxLength
AllowNull = False
Value = strValue
End Sub
Public Sub New(ByVal strValue As String,
ByVal intMinLength As Integer,
ByVal intMaxLength As Integer,
ByVal blnAllowNull As Boolean)
MinLength = intMinLength
MaxLength = intMaxLength
AllowNull = blnAllowNull
Value = strValue
End Sub
End Class