Does anyone know of a way to throw errors in vb.Net based on the error number? I need to build a list of just that since, as unnbeleivable as it sounds, MS apparently can't provide a table of error codes matched to their descriptions like they did in vb6. If that means they are too numerous to list, then if they can't stand the heat, get out of the kitchen, right?
Anyway, the Throw() method seems to be based on the user providing the error description so that the error can be thrown, and THEN you can query the Err structure to get the corresponding number. But I don't see a way of going in reverse...Providing an error number and having the exception thrown, so you can get at the description.
In that same regard, I could go back and use the error codes from vb6.....IF they matched up with the ones in vb.Net. That's one hell of an assumption!
The exceptions don't really have error numbers. The Err object is a hold over from the VB6 days. It's not used in VB.NET code. It's only there for backwards compatibility in old VB6 projects that were converted to VB.NET.
Well, my predicament is that I am finishing up a port-over of a vb6 project, with old style "On Error Resume and Goto" statements. So I need all possible errors that can be raised at certain spots. And since .net supports backward compatability, then the least they can do is show a table of vb6 error codes vs. descriptions. BUT then again, if this is TRUE backwards compatability, then the code numbers would not have changed. I hate making assumptions like that, though.
Still...Would be nice if they would put some of the old stuff in the net documentation, so you don't have to leave the net IDE to go look for a legacy feature that net supports. In that sense, it really IS part of net...Just not its new framework. I guess I'm just nitpicking.
Again. It has nothing to do with .NET at all. It's legacy junk that's only there for backwards compatibility. It offers nothing to .NET development and why would you duplicate documentation that is already out there and redocument language features that have been unsupported for years now?
It really is NOT part of .NET. What you see in a converted application are methods and hacks that look and work like old VB6 code. It's just a bunch of adaptations cobbled together to make .NET code look and work like old VB6 functionality.
I am having difficulty sorting a custom class based collection on two fields and am wondering if anyone can assist me. I have a class that looks like so:
ClassmyClassprivate ID asStringprivate Name asStringprivate TK asStringprivate Di asStringprivate M asStringEndClass
Using this class i add to a Collection a number of items, e.g.
Private colClass As Collection
Private clsTheClass AsmyClassSet colClass = New Collection
Set clsTheClass = NewmyClass
clsTheClass.Name = "A"
clsTheClass.TKs = "100"
clsTheClass.Di = "5"
clsTheClass.ID = "1"
clsTheClass.M = "9"
What i end up with it is a collection that looks like so after adding all the items:
ID |Name |TK |Di |M
1 A 100592 B 100393 C 10594 D 10795 E 10196 F 400957 F 40045
I need to sort the collection On TK, and then DI. That should make the collection look like this:
ID |Name |TK |Di |M
6 F 400957 F 400451 A 100592 B 100394 D 10793 C 10595 E 1019
I am currently using this method to sort on TK, but i cannot get it to work how i need the output:
PublicSub SortCollection(ColVar As Collection)
Dim oCol As Collection
Dim i AsIntegerDim i2 AsIntegerDim iBefore AsIntegerIfNot (ColVar IsNothing) ThenIf ColVar.Count > 0ThenSet oCol = New Collection
For i = 1To ColVar.Count
If oCol.Count = 0Then
iBefore = 0For i2 = oCol.Count To1Step -1
IfCLng(ColVar(i).TK) < CLng(oCol(i2).TK) Then
iBefore = i2
ElseExitForEndIfNextIf iBefore = 0Then
oCol.Add ColVar(i), , iBefore
EndIfEndIfNext'WE now have it sorted by TK in Asc order so we need to reverse it
'Reverse the collection
Dim MyNewCol AsNew Collection
Dim obj AsObjectForEach obj In oCol
If MyNewCol.Count > 0Then
MyNewCol.Add Item:=obj, before:=1
EndIfNextSet ColVar = MyNewCol
Set oCol = NothingEndIfEndIfEndSub
Anyone got any pointers as to what i need to change in the sort routine?
Whenever I sort, I find the largest, or the least first and set the value to "x". From there I work up, or down assigning to a temp object, collection or array, and replacing "x" as the largest each time.
x = 0
for each item in collection
if item > x then
x = item
This gets the largest to begin.
while tempcollection.count isnot collection.count
for each item in collection
set x if the item is less than the last in tempcollection and is not less than x
That is a level one sort, but you should be able to expand to code easily enough. Sorry that I lack any time, or I would have done it for you!
Last Visit: 31-Dec-99 19:00 Last Update: 1-Dec-15 7:06