Real Software Forums
http://forums.realsoftware.com/

Random String Function
http://forums.realsoftware.com/viewtopic.php?f=21&t=42651
Page 1 of 1

Author:  BuGs [ Sun Feb 12, 2012 5:06 am ]
Post subject:  Random String Function

This is an entire RS XML project so create an empty XML file and paste the entire code bellow, save it and then open it in RS.
<?xml version="1.0"?>
<RBProject version="2011r4" FormatVersion="2" MinIDEVersion="20070100">
<block type="Project" ID="0">
<ProjectSavedInVers>2011.04</ProjectSavedInVers>
<ProjMgrUser></ProjMgrUser>
<ProjMgrServer></ProjMgrServer>
<MajorVersion>1</MajorVersion>
<MinorVersion>0</MinorVersion>
<SubVersion>0</SubVersion>
<Release>0</Release>
<NonRelease>0</NonRelease>
<Region></Region>
<ShortVersion></ShortVersion>
<LongVersion></LongVersion>
<InfoVersion></InfoVersion>
<AutoIncVersion>0</AutoIncVersion>
<DefaultViewID>2109286399</DefaultViewID>
<ProjectType>0</ProjectType>
<DefaultLanguage>0</DefaultLanguage>
<CurrentLanguage>0</CurrentLanguage>
<DefaultEncoding>0</DefaultEncoding>
<BuildFlags>16384</BuildFlags>
<UseBuildsFolder>1</UseBuildsFolder>
<WebApp>0</WebApp>
<Icon>
</Icon>
<MacCreator></MacCreator>
<BuildCarbonName>My Application</BuildCarbonName>
<BuildCarbonMachOName>My Application</BuildCarbonMachOName>
<BundleIdentifier></BundleIdentifier>
<BuildSize>4194304</BuildSize>
<BuildMinSize>2097152</BuildMinSize>
<BuildSizeAsString>4096</BuildSizeAsString>
<BuildMinSizeAsString>2048</BuildMinSizeAsString>
<WinMDICaption></WinMDICaption>
<BuildWinName>My Application.exe</BuildWinName>
<BuildWinMDI>0</BuildWinMDI>
<BuildWinCompanyName></BuildWinCompanyName>
<BuildWinProductName></BuildWinProductName>
<BuildWinInternalName></BuildWinInternalName>
<UseGDIPlus>0</UseGDIPlus>
<BuildLinuxX86Name>MyApplication</BuildLinuxX86Name>
<DebuggerCommandLine></DebuggerCommandLine>
<WebPort>0</WebPort>
<WebProtocol>0</WebProtocol>
<WebDebugPort>8080</WebDebugPort>
<WebUseIntegratedBrowser>0</WebUseIntegratedBrowser>
<WebLaunchString>Launching...</WebLaunchString>
<WebHTMLHeader></WebHTMLHeader>
<WebDisconnectString>The application has gone off-line. Please try again later.</WebDisconnectString>
</block>
<block type="Module" ID="1901979647">
<ObjName>App</ObjName>
<ObjContainerID>0</ObjContainerID>
<IsClass>1</IsClass>
<Superclass>Application</Superclass>
<ItemFlags>1</ItemFlags>
<IsInterface>0</IsInterface>
<IsApplicationObject>1</IsApplicationObject>
<Compatibility></Compatibility>
<PropertyVal Name="MenuBar">903608319</PropertyVal>
<ViewBehavior>
</ViewBehavior>
<Constant>
<ItemName>kFileQuitShortcut</ItemName>
<Compatibility></Compatibility>
<Visible>1</Visible>
<TextEncoding>134217984</TextEncoding>
<ItemName>kFileQuitShortcut</ItemName>
<ItemType>0</ItemType>
<ItemDef></ItemDef>
<ItemFlags>0</ItemFlags>
<ConstantInstance>
<ItemPlatform>1</ItemPlatform>
<ItemLanguage>0</ItemLanguage>
<ItemDef>Cmd+Q</ItemDef>
</ConstantInstance>
<ConstantInstance>
<ItemPlatform>5</ItemPlatform>
<ItemLanguage>0</ItemLanguage>
<ItemDef>Ctrl+Q</ItemDef>
</ConstantInstance>
</Constant>
<Constant>
<ItemName>kFileQuit</ItemName>
<Compatibility></Compatibility>
<Visible>1</Visible>
<TextEncoding>134217984</TextEncoding>
<ItemName>kFileQuit</ItemName>
<ItemType>0</ItemType>
<ItemDef>&amp;Quit</ItemDef>
<ItemFlags>0</ItemFlags>
<ConstantInstance>
<ItemPlatform>2</ItemPlatform>
<ItemLanguage>0</ItemLanguage>
<ItemDef>E&amp;xit</ItemDef>
</ConstantInstance>
</Constant>
<Constant>
<ItemName>kEditClear</ItemName>
<Compatibility></Compatibility>
<Visible>1</Visible>
<TextEncoding>134217984</TextEncoding>
<ItemName>kEditClear</ItemName>
<ItemType>0</ItemType>
<ItemDef>&amp;Delete</ItemDef>
<ItemFlags>0</ItemFlags>
<ConstantInstance>
<ItemPlatform>2</ItemPlatform>
<ItemLanguage>0</ItemLanguage>
<ItemDef>&amp;Delete</ItemDef>
</ConstantInstance>
<ConstantInstance>
<ItemPlatform>5</ItemPlatform>
<ItemLanguage>0</ItemLanguage>
<ItemDef>&amp;Delete</ItemDef>
</ConstantInstance>
</Constant>
</block>
<block type="Window" ID="2109286399">
<ObjName>Window1</ObjName>
<ObjContainerID>0</ObjContainerID>
<IsClass>1</IsClass>
<Superclass>Window</Superclass>
<ItemFlags>1</ItemFlags>
<IsInterface>0</IsInterface>
<Compatibility></Compatibility>
<Method>
<ItemName>RandomString</ItemName>
<Compatibility></Compatibility>
<Visible>1</Visible>
<ItemSource>
<TextEncoding>134217984</TextEncoding>
<SourceLine>Function RandomString(CharactersCount As Integer = 5, LCaseString As Boolean = False, UCaseString As Boolean = False) As String</SourceLine>
<SourceLine>Dim Chrs, LstStr As String</SourceLine>
<SourceLine>Dim I, X, Y As Integer</SourceLine>
<SourceLine></SourceLine>
<SourceLine>Chrs = "abcdefghijklmnopqrstuvwxyz"</SourceLine>
<SourceLine></SourceLine>
<SourceLine>If (LCaseString = True) AND (UCaseString = True) Then</SourceLine>
<SourceLine>Chrs = Lowercase(Chrs) + Uppercase(Chrs)</SourceLine>
<SourceLine>ElseIf LCaseString = True Then</SourceLine>
<SourceLine>Chrs = Chrs</SourceLine>
<SourceLine>ElseIf UCaseString = True Then</SourceLine>
<SourceLine>Chrs = Uppercase(Chrs)</SourceLine>
<SourceLine>End If</SourceLine>
<SourceLine></SourceLine>
<SourceLine>I = 0</SourceLine>
<SourceLine>X = Len(Chrs)</SourceLine>
<SourceLine>LstStr = ""</SourceLine>
<SourceLine></SourceLine>
<SourceLine>do</SourceLine>
<SourceLine>Y = Round(Rnd * (X))</SourceLine>
<SourceLine>If Y &lt;&gt; 0 Then</SourceLine>
<SourceLine>If LstStr = "" Then</SourceLine>
<SourceLine>LstStr = Mid(Chrs, Y, 1)</SourceLine>
<SourceLine>I = I + 1</SourceLine>
<SourceLine>Else</SourceLine>
<SourceLine>LstStr = LstStr + Mid(Chrs, Y, 1)</SourceLine>
<SourceLine>I = I + 1</SourceLine>
<SourceLine>End If</SourceLine>
<SourceLine>End If</SourceLine>
<SourceLine>loop until I = CharactersCount</SourceLine>
<SourceLine></SourceLine>
<SourceLine>Return LstStr</SourceLine>
<SourceLine></SourceLine>
<SourceLine>End Function</SourceLine>
</ItemSource>
<TextEncoding>134217984</TextEncoding>
<AliasName></AliasName>
<ItemFlags>0</ItemFlags>
<Shared>0</Shared>
<ItemParams>CharactersCount As Integer = 5, LCaseString As Boolean = False, UCaseString As Boolean = False</ItemParams>
<ItemResult>String</ItemResult>
</Method>
<PropertyVal Name="ImplicitInstance">True</PropertyVal>
<PropertyVal Name="MenuBar">903608319</PropertyVal>
<PropertyVal Name="MacProcID">0</PropertyVal>
<PropertyVal Name="MinimizeButton">False</PropertyVal>
<PropertyVal Name="MaximizeButton">False</PropertyVal>
<PropertyVal Name="LiveResize">True</PropertyVal>
<PropertyVal Name="Resizeable">False</PropertyVal>
<PropertyVal Name="CloseButton">True</PropertyVal>
<PropertyVal Name="MenuBarVisible">True</PropertyVal>
<PropertyVal Name="FullScreen">False</PropertyVal>
<PropertyVal Name="Visible">True</PropertyVal>
<PropertyVal Name="Title">Random String Generator</PropertyVal>
<PropertyVal Name="Backdrop"></PropertyVal>
<PropertyVal Name="BackColor">16777215</PropertyVal>
<PropertyVal Name="HasBackColor">False</PropertyVal>
<PropertyVal Name="Composite">False</PropertyVal>
<PropertyVal Name="Frame">0</PropertyVal>
<PropertyVal Name="MaxHeight">32000</PropertyVal>
<PropertyVal Name="MaxWidth">32000</PropertyVal>
<PropertyVal Name="MinHeight">64</PropertyVal>
<PropertyVal Name="MinWidth">64</PropertyVal>
<PropertyVal Name="Height">122</PropertyVal>
<PropertyVal Name="Width">349</PropertyVal>
<PropertyVal Name="Placement">2</PropertyVal>
<ViewBehavior>
<ViewProperty>
<ObjName>Name</ObjName>
<Visible>1</Visible>
<PropertyGroup>ID</PropertyGroup>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>Interfaces</ObjName>
<Visible>1</Visible>
<PropertyGroup>ID</PropertyGroup>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>Super</ObjName>
<Visible>1</Visible>
<PropertyGroup>ID</PropertyGroup>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>Placement</ObjName>
<Visible>1</Visible>
<PropertyGroup>Position</PropertyGroup>
<PropertyValue>0</PropertyValue>
<ItemType>Integer</ItemType>
<EditorType>Enum</EditorType>
<InheritsFrom>Window</InheritsFrom>
<Enumeration>
<ItemDef>0 - Default</ItemDef>
<ItemDef>1 - Parent Window</ItemDef>
<ItemDef>2 - Main Screen</ItemDef>
<ItemDef>3 - Parent Window Screen</ItemDef>
<ItemDef>4 - Stagger</ItemDef>
</Enumeration>
</ViewProperty>
<ViewProperty>
<ObjName>Width</ObjName>
<Visible>1</Visible>
<PropertyGroup>Position</PropertyGroup>
<PropertyValue>600</PropertyValue>
<ItemType>Integer</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>Height</ObjName>
<Visible>1</Visible>
<PropertyGroup>Position</PropertyGroup>
<PropertyValue>400</PropertyValue>
<ItemType>Integer</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>MinWidth</ObjName>
<Visible>1</Visible>
<PropertyGroup>Position</PropertyGroup>
<PropertyValue>64</PropertyValue>
<ItemType>Integer</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>MinHeight</ObjName>
<Visible>1</Visible>
<PropertyGroup>Position</PropertyGroup>
<PropertyValue>64</PropertyValue>
<ItemType>Integer</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>MaxWidth</ObjName>
<Visible>1</Visible>
<PropertyGroup>Position</PropertyGroup>
<PropertyValue>32000</PropertyValue>
<ItemType>Integer</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>MaxHeight</ObjName>
<Visible>1</Visible>
<PropertyGroup>Position</PropertyGroup>
<PropertyValue>32000</PropertyValue>
<ItemType>Integer</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>Frame</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>0</PropertyValue>
<ItemType>Integer</ItemType>
<EditorType>Enum</EditorType>
<InheritsFrom>Window</InheritsFrom>
<Enumeration>
<ItemDef>0 - Document</ItemDef>
<ItemDef>1 - Movable Modal</ItemDef>
<ItemDef>2 - Modal Dialog</ItemDef>
<ItemDef>3 - Floating Window</ItemDef>
<ItemDef>4 - Plain Box</ItemDef>
<ItemDef>5 - Shadowed Box</ItemDef>
<ItemDef>6 - Rounded Window</ItemDef>
<ItemDef>7 - Global Floating Window</ItemDef>
<ItemDef>8 - Sheet Window</ItemDef>
<ItemDef>9 - Metal Window</ItemDef>
<ItemDef>10 - Drawer Window</ItemDef>
<ItemDef>11 - Modeless Dialog</ItemDef>
</Enumeration>
</ViewProperty>
<ViewProperty>
<ObjName>Composite</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>False</PropertyValue>
<ItemType>Boolean</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>HasBackColor</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>False</PropertyValue>
<ItemType>Boolean</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>BackColor</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>&amp;hFFFFFF</PropertyValue>
<ItemType>Color</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>Backdrop</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<ItemType>Picture</ItemType>
<EditorType>Picture</EditorType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>Title</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>Untitled</PropertyValue>
<ItemType>String</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>Visible</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>True</PropertyValue>
<ItemType>Boolean</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>FullScreen</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>False</PropertyValue>
<ItemType>Boolean</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>MenuBarVisible</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>True</PropertyValue>
<ItemType>Boolean</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>CloseButton</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>True</PropertyValue>
<ItemType>Boolean</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>Resizeable</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>True</PropertyValue>
<ItemType>Boolean</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>LiveResize</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>True</PropertyValue>
<ItemType>Boolean</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>MaximizeButton</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>False</PropertyValue>
<ItemType>Boolean</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>MinimizeButton</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>True</PropertyValue>
<ItemType>Boolean</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>MacProcID</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>0</PropertyValue>
<ItemType>Integer</ItemType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>MenuBar</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<ItemType>MenuBar</ItemType>
<EditorType>MenuBar</EditorType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
<ViewProperty>
<ObjName>ImplicitInstance</ObjName>
<Visible>1</Visible>
<PropertyGroup>Appearance</PropertyGroup>
<PropertyValue>True</PropertyValue>
<EditorType>Boolean</EditorType>
<InheritsFrom>Window</InheritsFrom>
</ViewProperty>
</ViewBehavior>
<ControlBehavior>
<Superclass>TextField</Superclass>
</ControlBehavior>
<ControlBehavior>
<Superclass>CheckBox</Superclass>
</ControlBehavior>
<ControlBehavior>
<Superclass>CheckBox</Superclass>
</ControlBehavior>
<ControlBehavior>
<Superclass>Label</Superclass>
</ControlBehavior>
<ControlBehavior>
<Superclass>TextField</Superclass>
</ControlBehavior>
<ControlBehavior>
<Superclass>PushButton</Superclass>
<HookInstance>
<ItemName>Action</ItemName>
<Compatibility></Compatibility>
<Visible>1</Visible>
<ItemSource>
<TextEncoding>134217984</TextEncoding>
<SourceLine>Sub Action()</SourceLine>
<SourceLine>Dim noChars As Integer</SourceLine>
<SourceLine>noChars = Val(txtNoChars.Text)</SourceLine>
<SourceLine>If noChars = 0 Then</SourceLine>
<SourceLine>noChars = 5</SourceLine>
<SourceLine>End If</SourceLine>
<SourceLine></SourceLine>
<SourceLine>If (chkLowerCase.Value = True) AND (chkUpperCase.Value = True) Then</SourceLine>
<SourceLine>txtResult.Text = RandomString(noChars, True, True)</SourceLine>
<SourceLine>ElseIf chkLowerCase.Value Then</SourceLine>
<SourceLine>txtResult.Text = RandomString(noChars, True, False)</SourceLine>
<SourceLine>ElseIf chkUpperCase.Value Then</SourceLine>
<SourceLine>txtResult.Text = RandomString(noChars, False, True)</SourceLine>
<SourceLine>Else</SourceLine>
<SourceLine>txtResult.Text = RandomString(noChars)</SourceLine>
<SourceLine>End If</SourceLine>
<SourceLine>End Sub</SourceLine>
</ItemSource>
</HookInstance>
</ControlBehavior>
<Control>
<ControlClass>TextField</ControlClass>
<ItemName>TextField</ItemName>
<PropertyVal Name="DataField"></PropertyVal>
<PropertyVal Name="DataSource"></PropertyVal>
<PropertyVal Name="AutomaticallyCheckSpelling">False</PropertyVal>
<PropertyVal Name="Alignment">0</PropertyVal>
<PropertyVal Name="AcceptTabs"></PropertyVal>
<PropertyVal Name="LimitText">0</PropertyVal>
<PropertyVal Name="ReadOnly"></PropertyVal>
<PropertyVal Name="Mask"></PropertyVal>
<PropertyVal Name="Text"></PropertyVal>
<PropertyVal Name="CueText"></PropertyVal>
<PropertyVal Name="Underline"></PropertyVal>
<PropertyVal Name="Italic"></PropertyVal>
<PropertyVal Name="Bold"></PropertyVal>
<PropertyVal Name="TextUnit">0</PropertyVal>
<PropertyVal Name="TextSize">0</PropertyVal>
<PropertyVal Name="TextFont">System</PropertyVal>
<PropertyVal Name="AutoDeactivate">True</PropertyVal>
<PropertyVal Name="HelpTag"></PropertyVal>
<PropertyVal Name="Visible">True</PropertyVal>
<PropertyVal Name="Format"></PropertyVal>
<PropertyVal Name="Enabled">True</PropertyVal>
<PropertyVal Name="BackColor">16777215</PropertyVal>
<PropertyVal Name="TextColor">0</PropertyVal>
<PropertyVal Name="UseFocusRing">True</PropertyVal>
<PropertyVal Name="Password"></PropertyVal>
<PropertyVal Name="Border">True</PropertyVal>
<PropertyVal Name="TabStop">True</PropertyVal>
<PropertyVal Name="TabIndex">0</PropertyVal>
<PropertyVal Name="TabPanelIndex">0</PropertyVal>
<PropertyVal Name="LockBottom"></PropertyVal>
<PropertyVal Name="LockRight"></PropertyVal>
<PropertyVal Name="LockTop">True</PropertyVal>
<PropertyVal Name="LockLeft">True</PropertyVal>
<PropertyVal Name="Height">20</PropertyVal>
<PropertyVal Name="Width">24</PropertyVal>
<PropertyVal Name="Top">13</PropertyVal>
<PropertyVal Name="Left">244</PropertyVal>
<PropertyVal Name="Scope">0</PropertyVal>
<PropertyVal Name="Super">TextField</PropertyVal>
<PropertyVal Name="Index">-2147483648</PropertyVal>
<PropertyVal Name="Name">txtNoChars</PropertyVal>
<ControlIndex>0</ControlIndex>
<Locked>0</Locked>
</Control>
<Control>
<ControlClass>CheckBox</ControlClass>
<ItemName>CheckBox</ItemName>
<PropertyVal Name="InitialParent"></PropertyVal>
<PropertyVal Name="DataField"></PropertyVal>
<PropertyVal Name="DataSource"></PropertyVal>
<PropertyVal Name="Value">True</PropertyVal>
<PropertyVal Name="State">1</PropertyVal>
<PropertyVal Name="Underline"></PropertyVal>
<PropertyVal Name="Italic"></PropertyVal>
<PropertyVal Name="Bold"></PropertyVal>
<PropertyVal Name="TextUnit">0</PropertyVal>
<PropertyVal Name="TextSize">0</PropertyVal>
<PropertyVal Name="TextFont">System</PropertyVal>
<PropertyVal Name="AutoDeactivate">True</PropertyVal>
<PropertyVal Name="HelpTag"></PropertyVal>
<PropertyVal Name="Visible">True</PropertyVal>
<PropertyVal Name="Enabled">True</PropertyVal>
<PropertyVal Name="Caption">Use Lowercase</PropertyVal>
<PropertyVal Name="TabStop">True</PropertyVal>
<PropertyVal Name="TabIndex">1</PropertyVal>
<PropertyVal Name="TabPanelIndex">0</PropertyVal>
<PropertyVal Name="LockBottom"></PropertyVal>
<PropertyVal Name="LockRight"></PropertyVal>
<PropertyVal Name="LockTop">True</PropertyVal>
<PropertyVal Name="LockLeft">True</PropertyVal>
<PropertyVal Name="Height">20</PropertyVal>
<PropertyVal Name="Width">100</PropertyVal>
<PropertyVal Name="Top">14</PropertyVal>
<PropertyVal Name="Left">20</PropertyVal>
<PropertyVal Name="Scope">0</PropertyVal>
<PropertyVal Name="Super">CheckBox</PropertyVal>
<PropertyVal Name="Index">-2147483648</PropertyVal>
<PropertyVal Name="Name">chkLowerCase</PropertyVal>
<ControlIndex>1</ControlIndex>
<Locked>0</Locked>
</Control>
<Control>
<ControlClass>CheckBox</ControlClass>
<ItemName>CheckBox</ItemName>
<PropertyVal Name="InitialParent"></PropertyVal>
<PropertyVal Name="DataField"></PropertyVal>
<PropertyVal Name="DataSource"></PropertyVal>
<PropertyVal Name="Value">False</PropertyVal>
<PropertyVal Name="State">0</PropertyVal>
<PropertyVal Name="Underline"></PropertyVal>
<PropertyVal Name="Italic"></PropertyVal>
<PropertyVal Name="Bold"></PropertyVal>
<PropertyVal Name="TextUnit">0</PropertyVal>
<PropertyVal Name="TextSize">0</PropertyVal>
<PropertyVal Name="TextFont">System</PropertyVal>
<PropertyVal Name="AutoDeactivate">True</PropertyVal>
<PropertyVal Name="HelpTag"></PropertyVal>
<PropertyVal Name="Visible">True</PropertyVal>
<PropertyVal Name="Enabled">True</PropertyVal>
<PropertyVal Name="Caption">Use Uppercase</PropertyVal>
<PropertyVal Name="TabStop">True</PropertyVal>
<PropertyVal Name="TabIndex">2</PropertyVal>
<PropertyVal Name="TabPanelIndex">0</PropertyVal>
<PropertyVal Name="LockBottom"></PropertyVal>
<PropertyVal Name="LockRight"></PropertyVal>
<PropertyVal Name="LockTop">True</PropertyVal>
<PropertyVal Name="LockLeft">True</PropertyVal>
<PropertyVal Name="Height">20</PropertyVal>
<PropertyVal Name="Width">100</PropertyVal>
<PropertyVal Name="Top">14</PropertyVal>
<PropertyVal Name="Left">132</PropertyVal>
<PropertyVal Name="Scope">0</PropertyVal>
<PropertyVal Name="Super">CheckBox</PropertyVal>
<PropertyVal Name="Index">-2147483648</PropertyVal>
<PropertyVal Name="Name">chkUpperCase</PropertyVal>
<ControlIndex>2</ControlIndex>
<Locked>0</Locked>
</Control>
<Control>
<ControlClass>Label</ControlClass>
<ItemName>Label</ItemName>
<PropertyVal Name="InitialParent"></PropertyVal>
<PropertyVal Name="DataField"></PropertyVal>
<PropertyVal Name="DataSource"></PropertyVal>
<PropertyVal Name="Underline"></PropertyVal>
<PropertyVal Name="Italic"></PropertyVal>
<PropertyVal Name="Bold"></PropertyVal>
<PropertyVal Name="TextUnit">0</PropertyVal>
<PropertyVal Name="TextSize">0</PropertyVal>
<PropertyVal Name="TextFont">System</PropertyVal>
<PropertyVal Name="AutoDeactivate">True</PropertyVal>
<PropertyVal Name="HelpTag"></PropertyVal>
<PropertyVal Name="Transparent">False</PropertyVal>
<PropertyVal Name="Selectable">False</PropertyVal>
<PropertyVal Name="Visible">True</PropertyVal>
<PropertyVal Name="Enabled">True</PropertyVal>
<PropertyVal Name="Multiline"></PropertyVal>
<PropertyVal Name="TextColor">0</PropertyVal>
<PropertyVal Name="TextAlign">0</PropertyVal>
<PropertyVal Name="Text">characters.</PropertyVal>
<PropertyVal Name="TabIndex">3</PropertyVal>
<PropertyVal Name="TabPanelIndex">0</PropertyVal>
<PropertyVal Name="LockBottom"></PropertyVal>
<PropertyVal Name="LockRight"></PropertyVal>
<PropertyVal Name="LockTop">True</PropertyVal>
<PropertyVal Name="LockLeft">True</PropertyVal>
<PropertyVal Name="Height">20</PropertyVal>
<PropertyVal Name="Width">64</PropertyVal>
<PropertyVal Name="Top">14</PropertyVal>
<PropertyVal Name="Left">272</PropertyVal>
<PropertyVal Name="Scope">0</PropertyVal>
<PropertyVal Name="Super">Label</PropertyVal>
<PropertyVal Name="Index">-2147483648</PropertyVal>
<PropertyVal Name="Name">Label1</PropertyVal>
<ControlIndex>3</ControlIndex>
<Locked>0</Locked>
</Control>
<Control>
<ControlClass>TextField</ControlClass>
<ItemName>TextField</ItemName>
<PropertyVal Name="DataField"></PropertyVal>
<PropertyVal Name="DataSource"></PropertyVal>
<PropertyVal Name="AutomaticallyCheckSpelling">False</PropertyVal>
<PropertyVal Name="Alignment">0</PropertyVal>
<PropertyVal Name="AcceptTabs"></PropertyVal>
<PropertyVal Name="LimitText">0</PropertyVal>
<PropertyVal Name="ReadOnly">True</PropertyVal>
<PropertyVal Name="Mask"></PropertyVal>
<PropertyVal Name="Text"></PropertyVal>
<PropertyVal Name="CueText"></PropertyVal>
<PropertyVal Name="Underline"></PropertyVal>
<PropertyVal Name="Italic"></PropertyVal>
<PropertyVal Name="Bold"></PropertyVal>
<PropertyVal Name="TextUnit">0</PropertyVal>
<PropertyVal Name="TextSize">0</PropertyVal>
<PropertyVal Name="TextFont">System</PropertyVal>
<PropertyVal Name="AutoDeactivate">True</PropertyVal>
<PropertyVal Name="HelpTag"></PropertyVal>
<PropertyVal Name="Visible">True</PropertyVal>
<PropertyVal Name="Format"></PropertyVal>
<PropertyVal Name="Enabled">True</PropertyVal>
<PropertyVal Name="BackColor">16777215</PropertyVal>
<PropertyVal Name="TextColor">0</PropertyVal>
<PropertyVal Name="UseFocusRing">True</PropertyVal>
<PropertyVal Name="Password"></PropertyVal>
<PropertyVal Name="Border">True</PropertyVal>
<PropertyVal Name="TabStop">True</PropertyVal>
<PropertyVal Name="TabIndex">4</PropertyVal>
<PropertyVal Name="TabPanelIndex">0</PropertyVal>
<PropertyVal Name="LockBottom"></PropertyVal>
<PropertyVal Name="LockRight">True</PropertyVal>
<PropertyVal Name="LockTop">True</PropertyVal>
<PropertyVal Name="LockLeft">True</PropertyVal>
<PropertyVal Name="Height">22</PropertyVal>
<PropertyVal Name="Width">309</PropertyVal>
<PropertyVal Name="Top">46</PropertyVal>
<PropertyVal Name="Left">20</PropertyVal>
<PropertyVal Name="Scope">0</PropertyVal>
<PropertyVal Name="Super">TextField</PropertyVal>
<PropertyVal Name="Index">-2147483648</PropertyVal>
<PropertyVal Name="Name">txtResult</PropertyVal>
<ControlIndex>4</ControlIndex>
<Locked>0</Locked>
</Control>
<Control>
<ControlClass>PushButton</ControlClass>
<ItemName>PushButton</ItemName>
<PropertyVal Name="InitialParent"></PropertyVal>
<PropertyVal Name="Underline"></PropertyVal>
<PropertyVal Name="Italic"></PropertyVal>
<PropertyVal Name="Bold">True</PropertyVal>
<PropertyVal Name="TextUnit">0</PropertyVal>
<PropertyVal Name="TextSize">0</PropertyVal>
<PropertyVal Name="TextFont">System</PropertyVal>
<PropertyVal Name="ButtonStyle">0</PropertyVal>
<PropertyVal Name="AutoDeactivate">True</PropertyVal>
<PropertyVal Name="HelpTag"></PropertyVal>
<PropertyVal Name="Visible">True</PropertyVal>
<PropertyVal Name="Enabled">True</PropertyVal>
<PropertyVal Name="Cancel"></PropertyVal>
<PropertyVal Name="Default">True</PropertyVal>
<PropertyVal Name="Caption">&amp;Generate Random String</PropertyVal>
<PropertyVal Name="TabStop">True</PropertyVal>
<PropertyVal Name="TabIndex">5</PropertyVal>
<PropertyVal Name="TabPanelIndex">0</PropertyVal>
<PropertyVal Name="LockBottom"></PropertyVal>
<PropertyVal Name="LockRight"></PropertyVal>
<PropertyVal Name="LockTop">True</PropertyVal>
<PropertyVal Name="LockLeft">True</PropertyVal>
<PropertyVal Name="Height">22</PropertyVal>
<PropertyVal Name="Width">169</PropertyVal>
<PropertyVal Name="Top">80</PropertyVal>
<PropertyVal Name="Left">155</PropertyVal>
<PropertyVal Name="Scope">0</PropertyVal>
<PropertyVal Name="Super">PushButton</PropertyVal>
<PropertyVal Name="Index">-2147483648</PropertyVal>
<PropertyVal Name="Name">btnGenerate</PropertyVal>
<ControlIndex>5</ControlIndex>
<Locked>0</Locked>
</Control>
</block>
<block type="Menu" ID="903608319">
<ObjName>MenuBar1</ObjName>
<ObjContainerID>0</ObjContainerID>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>FileMenu</ItemName>
<ItemText>&amp;File</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut></ItemShortcut>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>MenuItem</Superclass>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>FileQuit</ItemName>
<ItemText>#App.kFileQuit</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut>#App.kFileQuitShortcut</ItemShortcut>
<MenuShortcut>#App.kFileQuitShortcut</MenuShortcut>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>QuitMenuItem</Superclass>
</MenuItem>
</MenuItem>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>EditMenu</ItemName>
<ItemText>&amp;Edit</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut></ItemShortcut>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>MenuItem</Superclass>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>EditUndo</ItemName>
<ItemText>&amp;Undo</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut>Cmd+Z</ItemShortcut>
<MenuShortcut>Z</MenuShortcut>
<MenuShortcutModifier>1</MenuShortcutModifier>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>MenuItem</Superclass>
</MenuItem>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>UntitledMenu1</ItemName>
<ItemText>-</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut></ItemShortcut>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>MenuItem</Superclass>
</MenuItem>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>EditCut</ItemName>
<ItemText>Cu&amp;t</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut>Cmd+X</ItemShortcut>
<MenuShortcut>X</MenuShortcut>
<MenuShortcutModifier>1</MenuShortcutModifier>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>MenuItem</Superclass>
</MenuItem>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>EditCopy</ItemName>
<ItemText>&amp;Copy</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut>Cmd+C</ItemShortcut>
<MenuShortcut>C</MenuShortcut>
<MenuShortcutModifier>1</MenuShortcutModifier>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>MenuItem</Superclass>
</MenuItem>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>EditPaste</ItemName>
<ItemText>&amp;Paste</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut>Cmd+V</ItemShortcut>
<MenuShortcut>V</MenuShortcut>
<MenuShortcutModifier>1</MenuShortcutModifier>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>MenuItem</Superclass>
</MenuItem>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>EditClear</ItemName>
<ItemText>#App.kEditClear</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut></ItemShortcut>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>MenuItem</Superclass>
</MenuItem>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>UntitledMenu0</ItemName>
<ItemText>-</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut></ItemShortcut>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>MenuItem</Superclass>
</MenuItem>
<MenuItem>
<ItemSpecialMenu>0</ItemSpecialMenu>
<ItemName>EditSelectAll</ItemName>
<ItemText>Select &amp;All</ItemText>
<ItemIndex>-2147483648</ItemIndex>
<ItemShortcut>Cmd+A</ItemShortcut>
<MenuShortcut>A</MenuShortcut>
<MenuShortcutModifier>1</MenuShortcutModifier>
<MenuAutoEnable>1</MenuAutoEnable>
<TextEncoding>134217984</TextEncoding>
<ItemFlags>0</ItemFlags>
<Superclass>MenuItem</Superclass>
</MenuItem>
</MenuItem>
</block>
<block type="BuildAutomation" ID="399814655">
<ObjName>Build Automation</ObjName>
<ObjContainerID>0</ObjContainerID>
</block>
<block type="BuildStepsList" ID="1366056959">
<ObjName>Linux</ObjName>
<ObjContainerID>399814655</ObjContainerID>
</block>
<block type="BuildProjectStep" ID="830298111">
<ObjName>Build</ObjName>
<ObjContainerID>1366056959</ObjContainerID>
</block>
<block type="BuildStepsList" ID="1321699327">
<ObjName>Mac OS X</ObjName>
<ObjContainerID>399814655</ObjContainerID>
</block>
<block type="BuildProjectStep" ID="1766952959">
<ObjName>Build</ObjName>
<ObjContainerID>1321699327</ObjContainerID>
</block>
<block type="BuildStepsList" ID="2067124223">
<ObjName>Windows</ObjName>
<ObjContainerID>399814655</ObjContainerID>
</block>
<block type="BuildProjectStep" ID="846614527">
<ObjName>Build</ObjName>
<ObjContainerID>2067124223</ObjContainerID>
</block>
<block type="UIState" ID="0">
<WindowState>
<OpenTab>
<ObjContainerID>0</ObjContainerID>
<EditSplit>200</EditSplit>
<ProjectListSortColumn>3</ProjectListSortColumn>
<ProjectListColumnSortDirection>1</ProjectListColumnSortDirection>
</OpenTab>
<OpenTab>
<ObjContainerID>2109286399</ObjContainerID>
<LeftSplitter>138</LeftSplitter>
<RightSplitter>172</RightSplitter>
<ScrollX>0</ScrollX>
<ScrollY>0</ScrollY>
<LastPositionH>64</LastPositionH>
<LastPositionV>64</LastPositionV>
<Control>0</Control>
</OpenTab>
<OpenTab>
<ObjContainerID>2109286399</ObjContainerID>
<AlternateEditorID>1</AlternateEditorID>
<LeftSplitter>160</LeftSplitter>
<EmptyEventState>1</EmptyEventState>
<CodeItemID>0</CodeItemID>
</OpenTab>
<LastLocation>(Home)</LastLocation>
<EditBounds><Rect left="0" top="42" width="1280" height="942"/></EditBounds>
</WindowState>
<WarningPreferences>
<ItemName>5</ItemName>
<ItemData>0</ItemData>
<ItemName>6</ItemName>
<ItemData>0</ItemData>
<ItemName>7</ItemName>
<ItemData>0</ItemData>
<ItemName>9</ItemName>
<ItemData>0</ItemData>
<ItemName>10</ItemName>
<ItemData>0</ItemData>
<ItemName>11</ItemName>
<ItemData>0</ItemData>
</WarningPreferences>
</block>
</RBProject>


Original VB code: http://www.vbforums.com/showthread.php?t=633199

Author:  sinner [ Sun Feb 12, 2012 9:28 am ]
Post subject:  Re: Random String Function

This would be a simple way of converting that VB code to RB with less coding.

This example includes random numbers and letters

VB Converted URL
[url]
http://www.vbforums.com/showthread.php?t=633199
[/url]

Sub RandomString( CharactersCount as Integer , Caps As Boolean ) As String
For Chrs As Integer = 1 To CharactersCount
Dim LstStr As Integer = Rnd * 2
Dim Data As String
Select Case LstStr
Case 0
Data = Data + Chr(48 + Rnd * 9)
Case 1
Data = Data + Chr(65 + Rnd * 25)
Case 2
Data = Data + Chr(97 + Rnd * 25)
End Select
Next
If Caps Then Return UpperCase( Data ) Else Return LowerCase( Data )
End Sub


Call it just like you do on the VB forums

RandomString( 20, True ) 'Caps ON

Author:  silverpie [ Tue Feb 14, 2012 8:16 am ]
Post subject:  Re: Random String Function

And an optimization on that: instead of doing + to a string each time, make an array of strings and Join it at the end. It's a lot less overhead time.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/