Photo Gallery
Member List
Search
Calendars
FAQ
Ticket List
Log Out
Forums
Register
Login
My Profile
Inbox
Address Book
My Subscription
My Forums
Lining up tabs: More complicated than expected.
Logged in as: Guest
arrSession:exec spGetSession 2,16,62383
Active Users: There are
0
members and
0
guests.
Users viewing this topic: none
Printable Version
All Forums
>>
[Scripting]
>>
Post a VBScript
>> Lining up tabs: More complicated than expected.
Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page:
[1]
Login
Message
<< Older Topic
Newer Topic >>
Lining up tabs: More complicated than expected. -
7/15/2008 4:47:01 AM
geek_01
Posts: 12
Score: 0
Joined: 4/24/2006
From: So.Cal.
Status:
offline
I wonder if I did this the hard way, but I figured I would post it just for fun.
Basically it outputs text with the tabbed column lined up.
-Geek_01
Dim arrExample(9) Randomize arrExample(0) = String(RandomFourty,"!") arrExample(1) = String(RandomFourty,"@") arrExample(2) = String(RandomFourty,"#") arrExample(3) = String(RandomFourty,"$") arrExample(4) = String(RandomFourty,"%") arrExample(5) = String(RandomFourty,"*") arrExample(6) = String(RandomFourty,"(") arrExample(7) = String(RandomFourty,")") arrExample(8) = String(RandomFourty,"+") arrExample(9) = String(RandomFourty,"=") For Each strExample in arrExample If intMaxExampleLength < Len(strExample) Then intMaxExampleLength = Len(strExample) Next For i=LBound(arrExample) to UBound(arrExample) strOutput = strOutput & arrExample(i) & TabAlign(intMaxExampleLength,arrExample(i)) & "Example " & i & "." & VBCrLf Next Set objShell = CreateObject("Wscript.Shell") ScriptPath = objShell.CurrentDirectory Output ScriptPath & "\output.txt", strOutput Function Output(strFilePath,strOutput) Const OVERWRITE = True Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFile = objFSO.CreateTextFile(strFilePath, OVERWRITE) objFile.WriteLine strOutput objFile.Close Set WshShell = WScript.CreateObject("WScript.Shell") Return = WshShell.Run("notepad " & strFilePath, 1, true) End Function Function TabAlign(intMaxLength,strTextString) intTabLength = 8 numMaxTabWorth = intMaxLength/intTabLength If numMaxTabWorth = Int(numMaxTabWorth) Then intMaxTabWorth = numMaxTabWorth + 1 Else intMaxTabWorth = RoundUp(numMaxTabWorth) End If numTabWorth = Len(strTextString)/intTabLength If numTabWorth = Int(numTabWorth) Then intTabWorth = numTabWorth + 1 Else intTabWorth = RoundUp(numTabWorth) End If intTabCount = intMaxTabWorth - intTabWorth + 1 TabAlign = String(intTabCount,VBTab) TabAlign = TabAlign End Function Function RandomFourty RandomFourty = cint(rnd()*40 + 1) End Function Function RoundUp(Number) RoundUp = Round(Number+.5) End Function
Post #: 1
If you found our site useful please link to us
<a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>
.
All Forums
>>
[Scripting]
>>
Post a VBScript
>> Lining up tabs: More complicated than expected.
Page:
[1]
Jump to:
Select a Forum
All Forums
----------------------
[Welcome]
- - Forum Rules
- - Test Posting Messages
- - New Member Area/Introduction
[Scripting]
- - WSH & Client Side VBScript
- - WSH & Client Side VBScript Tutorial
- - Post a VBScript
- - Windows PowerShell
- - ASP
- - ASP.NET
- - Windows Script Components
[General Forum]
- - Other Programming/Scripting Languages
- - Suggestions & Feedback
- - Off-Topic Lounge
New Messages
No New Messages
Hot Topic w/ New Messages
Hot Topic w/o New Messages
Locked w/ New Messages
Locked w/o New Messages
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
Forum Software ©
ASPPlayground.NET
Advanced Edition
2.5.5 ANSI