-
Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Visual Basic 6
Code:
Private Type vbRECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type TEXTRUN
TextString As String
FontSize As Long
TextColor As Long
'Note: THIS FIELD IS NOT MEANT TO BE WRITTEN TO BY THE
'PROGRAMMER
CALCULATEDRECT As vbRECT
End Type
Private Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hDc As Long, ByVal lpStr As String, ByVal nCount As Long, lpRect As vbRECT, ByVal wFormat As Long) As Long
Private Declare Function DrawFocusRect Lib "user32" (ByVal hDc As Long, lpRect As vbRECT) As Long
Private Const DT_SINGLELINE = &H20
Private Const DT_CALCRECT = &H400
Private Const DT_CENTER = &H1
Private Const DT_VCENTER = &H4
Private Const DT_BOTTOM = &H8
Private Sub Form_Paint()
Dim text(0 To 2) As TEXTRUN
text(0).FontSize = 40
text(0).TextColor = RGB(255, 0, 0)
text(0).TextString = "Red"
text(1).FontSize = 25
text(1).TextColor = RGB(0, 0, 0)
text(1).TextString = " and "
text(2).FontSize = 40
text(2).TextColor = RGB(0, 0, 255)
text(2).TextString = "Blue"
DrawTextCentered text
End Sub
Private Sub Form_Resize()
Me.Refresh
End Sub
Private Sub DrawTextCentered(text() As TEXTRUN)
Dim previousScaleMode As Long
Dim prevFontSize As Long
Dim prevForeColor As Long
Dim textHeight As Long
Dim textWidth As Long
Dim textLeft As Long
Dim textTop As Long
Dim r As vbRECT
previousScaleMode = Me.ScaleMode
prevFontSize = Me.Font.Size
prevForeColor = Me.ForeColor
'We are assuming that when DrawText called on the Form's DC
'that the MM_TEXT mapping mode is used. MM_MODE is basically saying
'we are working in pixels. Because of this we need our
'Form to be measuring in pixels so we change the ScaleMode otherwise
'the only way to be sure is to import more of the Win32 API to measure
'in pixels.
Me.ScaleMode = vbPixels
For i = LBound(text) To UBound(text)
Me.Font.Size = text(i).FontSize
Me.ForeColor = text(i).TextColor
DrawText Me.hDc, text(i).TextString, -1, text(i).CALCULATEDRECT, DT_CALCRECT
If text(i).CALCULATEDRECT.Bottom > textHeight Then textHeight = text(i).CALCULATEDRECT.Bottom
textWidth = textWidth + text(i).CALCULATEDRECT.Right
Next
textLeft = (Me.ScaleWidth \ 2) - (textWidth \ 2)
textTop = (Me.ScaleHeight \ 2) - (textHeight \ 2)
For i = LBound(text) To UBound(text)
Me.Font.Size = text(i).FontSize
Me.ForeColor = text(i).TextColor
r.Left = textLeft
r.Top = textTop
r.Right = r.Left + text(i).CALCULATEDRECT.Right
r.Bottom = textTop + textHeight
DrawText Me.hDc, text(i).TextString, -1, r, DT_SINGLELINE Or DT_BOTTOM
'DrawFocusRect Me.hDc, r
textLeft = textLeft + text(i).CALCULATEDRECT.Right
Next
Me.ScaleMode = previousScaleMode
Me.Font.Size = prevFontSize
Me.ForeColor = prevForeColor
End Sub
https://www.vbforums.com/images/ieimages/2021/01/19.png
Visual Studio 2019 + XAML(VB.Net or C#)
Code:
<Grid>
<TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" >
<Run FontSize="40" Foreground="Red">Red</Run>
<Run FontSize="20"> and </Run>
<Run FontSize="40" Foreground="Blue">Blue</Run>
</TextBlock>
</Grid>
https://www.vbforums.com/images/ieimages/2021/01/20.png
Less typing. Works better.
*mic drop*
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
I'm just having a little fun with this topic. Don't you guys go taking this too seriously and start losing your minds.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
In VB6 IDE:
Code:
Dim myVerLongVariable As Long
Dim myVerLongVariable2 As Long
' Type myVer and CTRL-space
myVer .. myVerLongVariable
myVerLongVariable2
Name
Nothing
etc ..
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Holy wars in 10... 9... 8...
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Hahaha, this is ChitChat, so it better be not to serious :-)
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Arnoutdv
In VB6 IDE:
Code:
Dim myVerLongVariable As Long
Dim myVerLongVariable2 As Long
' Type myVer and CTRL-space
myVer .. myVerLongVariable
myVerLongVariable2
Name
Nothing
etc ..
Visual Studio 6 Intellisense
2 extra key presses to activate.
Visual Studio 2019 Intellisense
0 extra key presses to activate.
*mic drop*
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Arnoutdv
Hahaha, this is ChitChat, so it better be not to serious :-)
No reason we cannot have fun with our debates. I'm sick of them being so serious all the time. Let's lighten it up a bit.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Niya
Visual Studio 2019 Intellisense
0 extra key presses to activate.
Argh, are you serious? The same way Excel does when entering values in a cell. This annoys me like hell
*mute*
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
VB6
Code:
Dim names(0 To 2) As String
names(0) = "James"
names(1) = "Janet"
names(2) = "Marcus"
VB.Net
Code:
Dim names As String() = {"James", "Janet", "Marcus"}
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Arnoutdv
Argh, are you serious? The same way Excel does when entering values in a cell. This annoys me like hell
*mute*
I think you can disable the intellisense in Visual Studio 2019 or at least make it less aggressive. Not 100% sure because I don't ever want it disabled but I'm pretty sure I saw some stuff related to the intellisense when wading through settings.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Here's one for the other team.
Visual Studio 2019
Takes 3 seconds to start.
Visual Studio 6
Starts before I release my left click.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
I could post a ton of examples of stuff you can do with Linq, vb.net's collection types, and .NET file I/O class. I suppose vb6 is still okay for writing 32-bit applications, but try reading a text file into a string array with both. One language can do it with just about a single line. The other needs a dozen or so. And don't get me started on doing any serious processing on the data in the array such as sorting...
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Code:
Dim names As String() = {"James", "Janet", "Marcus"}
Yup, I really would like to be able to initialize of variables in the declare statement
Also annoying is the following and which is often done wrong with people unfamiliar with VB5/6:
Code:
Dim a As Long, b As Long, c As long
' instead of
Dim a, b, c As long ' causes a and b to be Variants
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Don't forget the built in refactoring hints, renaming of identifiers, support for .editorconfig, integrated unit tests, live unit testing, git integration, code lens, and it showing you all errors when you build - not just the first error it encounters.
Sure I will think of more things :D
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Peter Swinkels
I could post a ton of examples of stuff you can do with Linq, vb.net's collection types, and .NET file I/O class. I suppose vb6 is still okay for writing 32-bit applications, but try reading a text file into a string array with both. One language can do it with just about a single line. The other needs a dozen or so. And don't get me started on doing any serious processing on the data in the array such as sorting...
For text file I imagine most people have their own libraries for this.
I have a generic library for things like: FileToStringArray(), FileToByteArray() and a lot of other helper functions/classes
Which at the end is the same as the dozens of .Net libraries available.
Who wants to reinvent the wheel?
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Arnoutdv
Argh, are you serious? The same way Excel does when entering values in a cell. This annoys me like hell
*mute*
VS 2019 handles it really well, when you start typing an identifier it highlights the match in the intellisense but doesn't autocomplete it for you. Once it has highlighted an entry though you can act as if it had autocompleted.
e.g. to use Niya's example...
If I had
Code:
Dim myVerLongVariable As Long
Dim myVerLongVariable2 As Long
I could type my and the intellisense would highlight myVerLongVariable, if I then typed = 0 it would then autocomplete to myVerLongVariable = 0, if I continued typing more of a variable name it would carry on trying to suggest the best option. In fact it can now use machine learning to prioritise the intellisense based on previous usage of variables etc.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
@Arnoutdv:
True enough, I usually copy-paste procedures I wrote earlier specifically for those tasks and variable initialization is a godsend.
One of the thing I have to say in vb6's defense is that the IDE is so lightweight in comparisson to today's Visual Studio it runs really fast. If you have slightly older or low end pc that can make life easier. I also sometimes feel a bit lost exploring all the possibilities in .NET. I have had situations where I custom wrote something only to learn an alternative existed hidden in the multitude of .NET classes.
EDIT:
Sometimes I still mess with older BASIC dialects just for fun.. Say what you will about those ancient languages, they are small and lightweight. :-)
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Why is VB.Net/C#/XAML + VS2019 is better than VB6?
This is really why: NuGet
When you need something that is new but wide spread like MongoDb, Kafka, Neo4j, Redis, just name few of current tech that is in use everywhere, then the lack of similar libraries for forgotten languages like VB6 will "shine".
Language features (which many people here mess with libraries) are growing every year for .NET languages. Lambdas, attribute decorators, async functions, generics, dynamic objects, anonymous types... I can't even count how many of these features are not native in VB6 and need messy coding with lot of overhead.
Even some simple multiline string helps having cleaner code:
VB.NET Code:
Using conn = GetDbConn()
Dim query =
"SELECT
field1, field2, field3, field4
FROM Table1
WHERE
field2 LIKE @field2
"
Return conn.Query(query, New With {.field2 = "pattern%"})
End Using
Probably above code doesn't ring anything in most vb6-ers head, but the combination of language features + ORM library (Dapper) makes code really look clean, maintainable and easy to understand after long time if it requires some change.
And something that many VB6-ers dream of:
https://www.vbforums.com/images/ieimages/2021/01/25.png
(old example code when someone said that these old VB6 functions are not OK and will be discarded one day... or never?)
VB.NET supports even old outdated VB6 compatible functions and they work on Linux :D
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
PlausiblyDamp
Don't forget the built in refactoring hints, renaming of identifiers
These are two big ones for me. I use those features constantly. I don't think I want to live without them anymore.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
peterst
This is really why:
NuGet
Oh God yes!! I love Nuget. How did I forget to mention this.
Whoever came up with Nuget needs to worshipped. It makes it so painless to integrate 3rd party components into your projects and it takes care of a lot of potentially time consuming details like upgrading to newer versions of whatever components you're using. It is seriously one of my favorite additions to the software development eco-system.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Have fun? Is rubbing salt in a wound fun? Well, I suppose if it's not yours.
Any discussion like this is likely to be light hearted in that it has a chance of creating a flame war that will light more than just the heart. I have no love for this kind of discussion. I end up deleting more in such threads than everywhere else combined...including spam threads.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Peter Swinkels
I could post a ton of examples of stuff you can do with Linq, vb.net's collection types, and .NET file I/O class. I suppose vb6 is still okay for writing 32-bit applications, but try reading a text file into a string array with both. One language can do it with just about a single line. The other needs a dozen or so. And don't get me started on doing any serious processing on the data in the array such as sorting...
Dealing with files used to drive me absolutely nuts in QuickBasic and VB6 inherited this garbage. My biggest problem was that the Dir function had a single global search handle that was completely inaccessible to the programmer. VB6 also inherited this trash from QuickBasic. This made it incredibly difficult to write recursive file search algorithms. At least with VB6 we had the option of importing some Win32 APIs to help out. We had no choice in QuickBasic on DOS.
All of these problems completely went away in VB.Net. No more Dir. No more of that Get/Put garbage.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Shaggy Hiker
Have fun? Is rubbing salt in a wound fun? Well, I suppose if it's not yours.
Any discussion like this is likely to be light hearted in that it has a chance of creating a flame war that will light more than just the heart. I have no love for this kind of discussion. I end up deleting more in such threads than everywhere else combined...including spam threads.
Seems to be going fine so far.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Also, if any of them come across here, I won't bother engaging in any kind of fiery debate. They are free to mock VB.Net if they want, in fact I will welcome it as long as it can be in some kind of good spirit.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
In fact, I've said all I needed to say on the topic and Gods willing, this is the last thread of this nature I will be involved in. This thread is my coup de grĂ¢ce as far as this topic goes.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
@niya:
While impractical, especially by today's standards the functionality in old BASIC's could be extended by inserting bits of machine code or calling interrupts in Quick Basic. And API calls have the nasty tendency to cause weird errors or even crashes when used improperly.
And I don't mind these discussions, when I had enough of the last one I simply started ignoring it.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Niya
Seems to be going fine so far.
And well it might. The partisans tend not to frequent CC.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Peter Swinkels
@niya:
While impractical, especially by today's standards the functionality in old BASIC's could be extended by inserting bits of machine code or calling interrupts in Quick Basic. And API calls have the nasty tendency to cause weird errors or even crashes when used improperly.
And I don't mind these discussions, when I had enough of the last one I simply started ignoring it.
At the time such things were way beyond me. At 9 or 10 years old there was only so much I could really understand. BASIC was simple enough, but concepts like interrupts and whatnot were impossible for me to get at that age, especially with no internet to explain the same thing a billion different ways.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Arnoutdv
Also annoying is the following and which is often done wrong with people unfamiliar with VB5/6:
Code:
Dim a As Long, b As Long, c As long
' instead of
Dim a, b, c As long ' causes a and b to be Variants
I never understood why that was designed so. It's very unintuitive. It makes more sense for it to mean all of these variable are the same type so many will assume this is what it does.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
VB6
Code:
Private Sub Check1_Click()
ClickEvent Check1.Name
End Sub
Private Sub Command1_Click()
ClickEvent Command1.Name
End Sub
Private Sub Label1_Click()
ClickEvent Label1.Name
End Sub
Private Sub Option1_Click()
ClickEvent Option1.Name
End Sub
Private Sub ClickEvent(ByVal controlName As String)
MsgBox controlName + " was clicked"
End Sub
VB.Net
Code:
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim handler As EventHandler = Sub(ByVal s1 As Object, ByVal e1 As EventArgs)
MessageBox.Show(DirectCast(s1, Control).Name + " was clicked")
End Sub
For Each c As Control In Me.Controls
AddHandler c.Click, handler
Next
End Sub
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
VB6
Code:
Dim rects(0 To 2) As Rectangle
rects(0).Height = 45
rects(0).Width = 10
rects(0).X = 0
rects(0).Y = 0
rects(1).Height = 12
rects(1).Width = 22
rects(1).X = 0
rects(1).Y = 0
rects(2).Height = 22
rects(2).Width = 55
rects(2).X = 0
rects(2).Y = 0
Dim sum As Long
For i = LBound(rects) To UBound(rects)
sum = sum + rects(i).Height
Next
Debug.Print "The average height of the rectangles is " + CStr(sum / (UBound(rects) - LBound(rects) + 1))
VB.Net
Code:
Dim rects As Rectangle() = {New Rectangle(0, 0, 10, 45), New Rectangle(0, 0, 22, 12), New Rectangle(0, 0, 55, 22)}
Debug.WriteLine("The average height of the rectangles is " + rects.Average(Function(r) r.Height).ToString)
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
@niya:
I know what you mean, when you think about it it is kind of odd. I never knew what to do with machine code and interrupt calls until I found proper documentation on the internet during the late 90's by which time these programming methods were becoming obsolete. Where did you get the proper documentation during the 80's and early 90's? I guess you had to buy books or magazines. Or could you find such information in manuals? I vaguely remember my dad's 1991 80386 came with at least one thick paper manual.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
Peter Swinkels
@niya:
I know what you mean, when you think about it it is kind of odd. I never knew what to do with machine code and interrupt calls until I found proper documentation on the internet during the late 90's by which time these programming methods where becoming obsolete. Where did you get the proper documentation during the 80's and early 90's? I guess you had to buy books or magazines. Or could you find such information in manuals? I vaguely remember my dad's 1991 80386 came with at least one thick paper manual.
We got all of our information from programming books. Peter Norton has written books on programming that were available in the early 90s. I remember we had at least one of them here on programming in assembly. I remember as a child already programming in QuickBasic, trying to learn assembly it by reading that. I couldn't understand a damn thing about it. It was so different to programming in QuickBasic and far too advanced for my pre-teen mind to grasp.
But we also had a couple books on writing BASIC programs in BASICA. I don't remember who the authors were though. QuickBasic and QuickBasic Extended arrived later. QuickBasic Extended came with a bunch of programs from which we could learn. It also came with very good documentation on all of it's operators, keywords, and library functions. The documentation also had a few samples if memory served.
In the early 90s we basically had to scrape and claw for whatever little information we can get. The good thing about it was that systems were far less sophisticated than today so we really didn't need that much information. Going back to the QuickBasic Extended documentation, while it was great in it's time, it's barely a mosquito bite of knowledge compared to what the MDSN library is today. That's mainly because so much more knowledge is needed to function in today's world as a software developer.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Also don't forget about the entire Async / Await approach that is built into the compiler / framework now, an absolute game changer compared to handling your own threading etc.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Quote:
Originally Posted by
PlausiblyDamp
Also don't forget about the entire Async / Await approach that is built into the compiler / framework now, an absolute game changer compared to handling your own threading etc.
As I understand it, this language feature is becoming very popular in modern languages including Python, Dart and Rust. When it was first introduced to .Net I was blown away at it's elegance compared to writing multithreaded and asynchronous code the old fashion way. Though I admit, I still do a lot of multithreading the old fashion way. I do love this new way of doing it and will be utilizing it more in the future.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
Multithreading depends on the goal. Sometimes the parallel library is enough for many tasks - I posted in the PSC thread app to migrate old CDs to centralized Git hosting (I've included only implementation for Gitea). With Parallel.For the decryption and extraction time of archives was reduced several times (from an hour to less than 10 minutes). To access Gitea web API async/await is used.
What I have seen in practice is the real performance comparison between old VB6 app and same code re-written just to use .NET Framework libraries. 35-40 minutes vs 35-40 seconds. Even without multithreading (4 tasks in parallel for part of the processing) it took about 2 minutes. And this procedure is used in production by human 20-30 times a day to find what's wrong, fix manually and then check again the data.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
@niya:
Now that you mention it I have heard about Peter Norton. I don't think assembly is hard to understand because it is advanced, but rather because it is so abstract relative to higher level languages and requires a much more in depth understanding of the hardware achitecture.
Oh, and multithreading:
This brings up memories of messing with ON TIMER - yeah not really multithreading but still... :-) And I actually once downloaded a TSR written in Quick Basic. I don't remember, but it probably had a ton of embedded machine code.
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
I always find this talk of VB6 and .Net so entertaining having come from a world of Digital PDP-11 and VAX-11 minicomputers (at least DEC had BASIC) and various IBM mainframes (where you had to work with COBOL).
When a new machine was released, the first thing you would do is write code to talk to the screen and keyboard - those were the first libraries you needed. Then you would create your database libraries. Back on the PDP/11's (this is 1980) you home-grew your own ISAM system - quick sorts that created "pointer" files and other various indexes. When we got to VAX/VMS that whole "i/o" system was RDBMS based - something Microsoft dreamed of (some abandoned project that would have taken disk DOS and migrated it into SQL world - can't remember the project code name).
I didn't move my clients off VAX's until around 1999 - MS SQL 2000 was new and seemed powerful enough to take the place of our homegrown RDBMS systems. .Net was too new, so I went with VB6.
Bottom line - every platform needs libraries - today most are spoiled by simply being given those libraries and never understanding those basics and internals.
Peter Norton - no -Donald Knuth's books on algorithms - yes!
Although I must say the most important book I purchased on my path from minicomputer to MS/PC/SQL was Kalen Delaney's Inside Microsoft SQL Server 2000 - that book is one hell of a good read, at least to database nerds like me, lol!
I was able to login to an "emulated" VAX that a client of mine still has - here's an old MACRO-11 (assember) function to turn a string into "upper/lower case" and do it IN PLACE in memory as opposed to moving to a new string - things that were important for speed back in the day, lol!
I wrote this function a year out of high school. DEC had just released a new VAX/VMS machine that we were going to migrate our PDP/11 "school admin" software to.
Here's a challenge - try to understand the first 5 lines of code - how it works with both 2 parameters (move from one string to another) or 1 parameter (work with string in place). And for those more interested in the details please note that a "string pointer" was made up or a longword for "address" and a word for length and a word for misc info. I love the opcode SOBGTR - "subtract one and branch if greater than zero"
Code:
$ set def [antares.lib.src]
$ type uplow.mar
.TITLE UPPER_LOWER_CASE
.IDENT /V1.0/
;
;
; Converts ORG_STR to Upper and lower case OUT_STR
;
; SCZ at 02-Jun-1982
;
; CALL UPPER_LOWER_CASE( ORG_STR_ADDR BY VALUE, OUT_STR )
;
; CALL UPPER_LOWER_CASE( STR )
;
;
.ENTRY UPPER_LOWER_CASE,^M<R2,R3,R4,R5>
START: MOVL (AP)+,R5 ; Get # of args
CMPL #1,R5 ; Only one arg?
BEQL 6$ ; Yes - Update in place
MOVL (AP)+,R2 ; Address of original string
6$: MOVL (AP)+,R3 ; Address of Out_str descrpt
CLRL R4 ; Zero R4
MOVW (R3)+,R4 ; Len of output string
TSTW R4 ; Test for zero length
BEQL EXIT ; Nothing to do if zero
MOVW (R3)+,R0 ; Jump over 2nd word
MOVL (R3)+,R3 ; Get addr of output string
CMPL #1,R5 ; Updating in place?
BNEQ 7$ ; No - Start move
MOVL R3,R2 ; Yes - Point in/out to same
;
7$: MOVB (R2)+,(R3)+ ; Move first byte
SUBB2 #1.,R4 ; Subtract one from len
BNEQ 1$ ; 1 chr string?
BRB EXIT ; Yes - exit
1$: CLRL R5 ; Zip out R5
MOVB (R2)+,R5 ; Put the byte into R5
CMPB R5,#32. ; Is byte a <SPACE> ??
BGTR 2$ ; Goto 2$ if not space
MOVB R5,(R3)+ ; Move the space
MOVB (R2)+,(R3)+ ; and next byte
SUBB2 #1.,R4 ; Sub 1 from R4 (len)
SOBGTR R4,1$ ; Go get next byte (if any)
BRB EXIT ; All done
;
2$: CMPB R5,#64. ; Is byte a "@" ??
BGTR 3$ ; Goto to 3$ if greater than @
BRB 4$ ; If not goto 4$
3$: CMPB R5,#91. ; Is byte a "["
BLSS 5$ ; Goto to 5$ if less than [
4$: MOVB R5,(R3)+ ; Move the byte
SOBGTR R4,1$ ; Go get next byte (if any)
BRB EXIT ; All done
;
; If we get here than we must change ASCII
;
5$: ADDB2 #32.,R5 ; Add 32 to ASCII (upper case now)
MOVB R5,(R3)+ ; Move the new character
SOBGTR R4,1$ ; Do more if any
EXIT: MOVL #1.,R0 ; Return SS$_NORMAL
RET ; And exit
.END
$
-
Re: Why is VB.Net/C#/XAML + VS2019 is better than VB6? Here's why.....
@szlamany - I think it's impressive anyone can write code like that... It must take a lot skill and knowledge to pull off.