Page 12 of 18 FirstFirst ... 29101112131415 ... LastLast
Results 441 to 480 of 695

Thread: Vb6 , the Future, and what I have discovered

  1. #441
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Schmidt View Post
    Yeah - we had this topic already, so: SCNR (but you guys keep mentioning this alleged "productivity increasing stuff" again and again)...

    Olaf
    Who? I don't want to review this whole thread, but the only recent mention of "productivity increasing stuff" was saying that it was VB6 that was productivity increasing.
    My usual boring signature: Nothing

  2. #442
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Shaggy Hiker View Post
    Who? I don't want to review this whole thread, but the only recent mention of "productivity increasing stuff" was saying that it was VB6 that was productivity increasing.
    Ok, just looking through the last 10 posts, I've already found 3 snippets which don't really suggest to me, that you are convinced that VB6 is sufficient as it is.

    Quote Originally Posted by Sitten Spynne View Post
    ...What I see is a consensus VB6 developers would like to learn a language "exactly like VB6" to the extent that new features should be rejected ...
    The above sounds as if it is a bad thing, that "new features are rejected" - my point being: there are no new features which are worth talking about (language-wise, not library-wise).

    Quote Originally Posted by Niya View Post
    ... better hardware came along and made all of that unnecessary, which is one of the pitfalls of staying too long in outdated tech...
    The above suggesting, that we use "outdated tech" (which is entirely wrong - COM is the base for the new UWP - and "native-compiling" is currently promoted as one of the most important features of the new .NET-core 2.0).
    VB6 already supports all of that, so it's not "outdated tech" (seems to me, that .NETers who currently don't use the new .NET-core 2.0 and don't write UWP-stuff - are using outdated tech).

    Quote Originally Posted by Shaggy Hiker View Post
    ...People are doing some amazing stuff with VB6, but they are doing it by extending the language and really getting into it. The basic stuff is simple....beyond that...is it really?

    And also your quote above suggests the "same old, same old" (VB6 is good only at the "simple things", not with the "complex ones").
    Your statement avove clearly suggests to me, that there is "something out there, something magical" (which can make also the complex things easier).

    You seem to have experienced that "magic" in some tool I guess - so which one ist it?
    And can you give a small example for the "magic" whilst solving a more complex problem?

    Shaggy, I truly don't try to "rile you all up" here - it's just that I so far never came across an example in the last years,
    which truly impressed me (whilst looking at and experimenting with other languages) - I've had the VB6-equivalent immediately in mind for all the new "code-snippets" I've seen.

    Olaf

  3. #443
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Schmidt View Post
    Ok, just looking through the last 10 posts, I've already found 3 snippets which don't really suggest to me, that you are convinced that VB6 is sufficient as it is.
    If you mean me specifically, then you have misread or misunderstood those posts. I have no opinion one way or another as to the sufficiency of VB6, nor do I care. I used the language a long time ago. I still have programs running in that language. I don't use it now. If I go back to it, I go back to it, and I'd be completely indifferent either way. Until people on this forum started talking about it, I assumed that everybody felt that way.
    My usual boring signature: Nothing

  4. #444
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Shaggy Hiker View Post
    I have no opinion one way or another as to the sufficiency of VB6, nor do I care.
    Then I apparently misunderstood your statement:
    "...they are doing it by extending the language and really getting into it. The basic stuff is simple....beyond that...is it really?"

    That somehow reads, like I wrote already, as if we are *in need* to "extend the language" (to be able to tackle "the advanced stuff").

    I'm fine, when you don't want to explain your statement further -
    but would appreciate a few more comments, how you wanted the thing to be understood...
    <shrug>

    Olaf

  5. #445
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Vb6 , the Future, and what I have discovered

    Yeah, by that definition of extending it, I can see how you read it. You aren't changing the language itself, so it isn't an extension in that regard. I suppose somebody might say that an OCX is an extension, but that isn't what I meant, either.

    When I got into VB5, I had a book that had all the functions (at least it seemed that way, it was pretty massive, but I don't have it any longer). The way things like threading are being done didn't appear to be in the canon of VB6 as envisioned by MS. People then went and worked out how to use VB6 to do multi-threading at a time when MS didn't appear to even acknowledge that it was possible in the language. That's what I meant by extending it: Getting it to do things that MS wasn't stating it could do. I suppose that isn't technically extending the language, as it used features already present, but it did appear to push the bounds that MS had loosely set.

    I meant it as a compliment to those people who are delving into every nook and cranny in the language, nothing else. I suppose that makes it ironic that you took it as you did. Sometimes, the flatness of the written language lets us down.
    My usual boring signature: Nothing

  6. #446
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Shaggy Hiker View Post
    People then went and worked out how to use VB6 to do multi-threading at a time when MS didn't appear to even acknowledge that it was possible in the language.
    That's what I meant by extending it: Getting it to do things that MS wasn't stating it could do.
    JFYI...
    VB6 was built to officially support "save to use threading, without the need to write any synchronization-code"...
    Over those well-known COM-threads, which are fired up with one (or more) Object-Instances that run on it - and then work in so called "Single-Threaded-Apartments" (STAs).
    For better isolation (to better support "synchronizied cross-thread-access"), each of these Threads was using a fully separated (isolated) Memory-Allocator
    (the so called "Thread-Local-Storage" - TLS).

    There even was an official VB6-Demo for that approach, provided by MS (the wellknown "Coffee-example"):
    https://msdn.microsoft.com/en-us/lib...(v=vs.60).aspx

    Quote Originally Posted by Shaggy Hiker View Post
    I meant it as a compliment to those people who are delving into every nook and cranny in the language, nothing else. I suppose that makes it ironic that you took it as you did.
    I'm not offended, or "enraged" or something - but these are "publically visible threads", read by a lot of people -
    who then form their opinions more on "the gut-feeling" they take with them (after leaving the thread)...
    (which could be an entirely wrong one, when they read too many of those "VB6 == stone-age" comments).

    So I'm not writing "to get something off my chest" personally - I write more for "those guys out there".

    I also have absolutely no "bad feelings" towards .NET ... it's "just another language+platform" (like Java) -
    one which (for my personal taste) has disadvantages (like e.g. the Garbage-Collector), which do not outweigh
    the advantages (as e.g. those inherent in the Garbage-Collector ...
    (since it allows "mass-instantiations, followed by mass-destruction" of hundreds of thousands of small class-instances
    *much* faster than VB6 - due to the concepts and interactions of the VM and the GC).

    Olaf

  7. #447
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Vb6 , the Future, and what I have discovered

    I've always been puzzled by the GC stuff. This has never had any noticeable negative impact on any .NET program I have ever seen. I realize that it would have a potentially devastating impact on real time games, but I wouldn't think that would be even the top reason not to use a managed language for that type of program. When it comes to LOB applications, which is all I write, I would think it likely that the GC NEVER runs during the operation of the program, which is pretty efficient.
    My usual boring signature: Nothing

  8. #448
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Shaggy Hiker View Post
    I've always been puzzled by the GC stuff. This has never had any noticeable negative impact on any .NET program I have ever seen.
    If you deal with it correctly - or don't use "loads of class-instances" (where a GC-run might kick-in later, at an inconvenient time),
    then it won't (have a negative impact).

    It's perhaps not that often, that you encounter such scenarios "at App-Level" - but when you are a "Library-Author" (who wraps C-Dlls) -
    then "destroy-order" is important (e.g. when you'd wrap the flat GDI-API or the SQLite-API behind .NET-Classes).

    In these cases you cannot "blindly trust" the GC with disposing your GDI-hPen-ClassInstance or your GDI-hDC-ClassInstance
    in the right order (with regards to the "Handle-freeing").

    Olaf

  9. #449
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Vb6 , the Future, and what I have discovered

    Pfff, geez. I'm particularly slow at times.

    As I was re-reading through a couple of things in this thread, I just "got" Shaggy's pun in post #403. Geez, I took him literally and started a discussion on code volume metric. LMAO.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  10. #450
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Schmidt View Post
    In these cases you cannot "blindly trust" the GC with disposing your GDI-hPen-ClassInstance or your GDI-hDC-ClassInstance
    in the right order (with regards to the "Handle-freeing").
    You're not supposed to rely on the GC to free OS resources like GDI objects and file handles. The correct way to handle this is to wrap these OS objects in a managed object and implement the IDisposable interface and a finalizer. The Dispose method of the IDisposable interface is meant to be used to explicitly free unmanged resources.

    And if you're coding against the raw Win32 API without wrappers then the GC has no relevance. You would be using the same patterns as anyone using the Win32 API in any other language or runtime. IE, you would be freeing things explicitly, eg. CloseHandle, DeleteObject etc.
    Last edited by Niya; Feb 14th, 2018 at 10:01 AM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  11. #451
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Niya View Post
    You're not supposed to rely on the GC to free OS resources like GDI objects and file handles. The correct way to handle this is to wrap these OS objects in a managed object and implement the IDisposable interface and a finalizer. The Dispose method of the IDisposable interface is meant to be used to explicitly free unmanged resources.
    Sure - you will have to know (and think) about that - and correctly implement your wrapper-stuff with that.
    And as a convenience, there's even the "Using"-Block you could apply, which does the "disposing" automatically at the end of the Using-block.

    So, when you are using a "Wrapper-Class for a flat-API" from the .NET-framework
    (like e.g. the httpClient - which wraps Socket-APIs and -Handles underneath) you could do this:
    Code:
    using(var client = new HttpClient()) {
        //do something with http client
    }
    Am I right?

    Olaf

  12. #452
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Vb6 , the Future, and what I have discovered

    Hahaha you picked, perhaps by luck, the absolute worst example and I want to beat someone at Microsoft with a club for it.

    NORMALLY you would be right. The onus is on a .NET developer to check if the types she creates implement IDisposable, and if so a using block is a good way to safely manage them. Otherwise, it's the dev's job to make sure Dispose() gets called on it at some time. It's sort of like they reintroduced us to malloc() and free(), don't get me started on how much I hate the IDisposable pattern.

    OK, but HttpClient is weird. The object itself hides the fact that most of its state is static, so if you create 100 HttpClient objects, they're all sharing the same internal state objects, with some infrastructure to keep everything straight.

    But because it's this weird half-static half-instance kind of object, that means calling Dispose() in it is really bad. There are some bits of information related to the socket states it was managing that aren't static, but could be, so it's not safe for Dispose() to try and actually clean them up: it's better for it to let them time out and die on their own. BUT. This means if you're creating bunches of HttpClient objects, doing one thing with them, then Disposing like a good developer, you end up with a ton of sockets just hanging out in a state where nobody can do anything with them until they time out, because if an instance didn't explicitly open that socket it's too afraid to terminate it. Bleh.

    So you're supposed to make just one HttpClient object and use that for everything. What happens then is if you're using it heavily and it starts to notice sockets backing up, it goes ahead and cleans itself up. Since it's the only one around apparently it can do that, I don't know. This isn't even in the documentation, you have to follow smart people on Twitter and find out via blogs.

    By analogy with COM:

    It's like MS decided to make AddRef() for this object set up a lot of instance-local stuff, but also store some things in a static context that'll be shared by multiple instances. So then they made Release() get rid of the instance-local stuff, but only the static stuff that has ONLY been touched by this object. So if you call AddRef() twice, some percentage of your static state can't be cleaned up by Release(). That percentage gets bigger every time you call AddRef(). The only solution is to only ever request one instance, and only call AddRef() once, even if you're using it in multiple places.

    Thanks, Microsoft. I want to stress again: this is NOT normal IDisposable logic, and as far as I know this is the only type in the framework with this specific behavior. EVERY other time MS wanted us to just use one instance of an object, they made the whole object static (which makes it behave like a Module, really.) Or they implemented the Singleton pattern. But they messed up HttpClient really badly!
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  13. #453
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Sitten Spynne View Post
    Hahaha you picked, perhaps by luck, the absolute worst example and I want to beat someone at Microsoft with a club for it.
    Nah, not by luck (you should know me in the meantime <g>)...

    Because I was going to post this here in reply:
    https://aspnetmonsters.com/2016/08/2...tpclientwrong/

    But you beat me to it (and thanks for giving a bit more background-info, which the above link also sheds some light on).

    That said - the question remains, why MS "****ed up" in this case?
    (could be, that it was "a C++ team, more familiar with COM" who wrote the C# wrapper)

    The COM-implementation of WinHttp does not show such a weird behaviour.

    Olaf

  14. #454
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Vb6 , the Future, and what I have discovered

    I don't know why HttpClient displays this particular behavior. There are a couple of other ways to go about making HTTP requests in .NET that are older and clunkier but behave like you'd expect. I think what happened based on some vague statements I've seen is all of the old things use some particular COM/WinAPI stack, but HttpClient uses some newer stack that showed up sometime in the Win7/8 timeframe. I'm suspicious something about that stack is related to WinRT/Metro/UWP/whatever they call it next year, because they could have just added new members to the older types if the only goal was "bring new asynchronous patterns to the HTTP experience". So they probably designed the initial implementation for some super-limited environment like Windows Phone and didn't think the implications all the way through? I don't know, and we'll probably never get the story.

    I experienced something similar once when I was the person wrapping a C API. There was a callback I had to provide a delegate to, but the API was bad and didn't have a method to tell it to stop calling the callback. If you called Dispose(), this was OK, because I went about freeing the handle. Unfortunately I was having to write an object that referenced the object that held the handle. This is where it gets tricky.

    If you call Dispose() on my outer object, everything's peachy. I Dispose() the inner object, and it frees its handle, and everyone's happy. If you forget to call Dispose() on my outer object, we get into the Twilight Zone. That means, at some point, the Garbage Collector's going to destroy my outer object. I had a Finalizer, which is like an emergency "you forgot to call Dispose()" hatch. HOWEVER, in this case it's very, very pathological. Let's say the GC decides to destroy my outer object first. An important rule of finalizers is "do not touch other .NET objects you reference, for the order of finalization is non-deterministic". That means the only thing it's safe to touch is your unmanaged handles, since the GC won't mess with them. At "the end of the program", when everything is closing, all finalizers are going to get called, but you don't know what order. It's a mess.

    So, I can't dispose the inner object because I'm worried it might not really exist anymore. That made the finalizer for the outer object mostly useless, but it had some other things to do that were worth doing. Now, what if that inner object isn't dead yet? Remember that callback? The unmanaged object's out there, and it decides to call the callback. That calls a method on the inner object. That causes it to raise an event, which the outer object was subscribed to. What's an event in .NET? A delegate call. So it tries to call the event handler on the outer object... which has been destroyed by the GC... and... oh no. App crash time.

    You can't detect that case. It's supposed to not be able to happen. "What if the GC collected a thing I reference?" can only happen during finalization, and that's why they urge you to not write finalizers. So when you try to touch a pointer to an object the GC has already collected, it's WORSE than a null reference. You can detect a null reference and avoid it. Even TRYING to see if this object is null will crash you.

    I wrote code for "not-programmer" customers. Forgetting to call Dispose() is what they do best. I forget why, but there were very good reasons at the time why I couldn't collapse the inner and outer object into one object, thus making it safe to free the handle. I think, today, with 8 years more experience, I'd tell my boss his pretty architecture had to go to make the code safer. But that particular type was shared by a ton of code and we were very worried about making breaking changes. Writing APIs does that to you.

    So I had to make a compromise, break the rule, and try calling Dispose() on the inner object. It meant when my users forgot to call Dispose(), 99% of the time nothing bad happened and they didn't leak memory. 1% of the time, it crashed, and we heavily bolded the documentation that told them to use Dispose(). And if they closed the application without proper Dispose() logic, it crashed 100% of the time, real amazing how consistent it was. Neat trick though: an app crash during shutdown is completely silent, it doesn't raise a dialog or even hit the Event Log.

    So help me, if someone designs a VB7 and puts something like the Disposable pattern in it, the club-beating I mentioned before will also be reserved for that person. It is the most awful aspect of .NET and only works if the C/COM APIs you are consuming follow very good rules. Luckily for us, the GDI stuff follows those rules.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  15. #455
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Schmidt View Post
    So, when you are using a "Wrapper-Class for a flat-API" from the .NET-framework
    (like e.g. the httpClient - which wraps Socket-APIs and -Handles underneath) you could do this:
    Code:
    using(var client = new HttpClient()) {
        //do something with http client
    }
    Am I right?

    Olaf
    Yes:-
    vbnet Code:
    1. '
    2.         Using b As New SolidBrush(Color.Blue)
    3.             DoBrushStuff(b)
    4.         End Using

    Using blocks are implemented by the compilers of both VB.Net and C#. The MSIL code emitted by the VB.Net compiler for the above would be equivalent to writing this:-
    vbnet Code:
    1. '
    2.         Dim b As New SolidBrush(Color.Blue)
    3.  
    4.         Try
    5.             DoBrushStuff(b)
    6.  
    7.             'Finally blocks will ALWAYS execute
    8.             'before the current method returns.
    9.         Finally
    10.             If TypeOf b Is IDisposable Then
    11.                 DirectCast(b, IDisposable).Dispose()
    12.             End If
    13.         End Try

    The two main things are the check for IDisposable interface and the finally block. The IDisposable check is pretty straightforward. It ensures that it's safe to use Using blocks with objects that don't implement the IDisposable interface. The finally block makes it possible to return from the current procedure from within the Using block without having to worry about the object not being disposed:-
    vbnet Code:
    1. '
    2.         Using b As New SolidBrush(Color.Blue)
    3.             DoBrushStuff(b)
    4.  
    5.             'The compiler wraps the Dispose call within a Finally block
    6.             'so Dispose will be called even if we return from inside the block
    7.             Return
    8.  
    9.         End Using

    I noticed you used C# in your example. In case you're more comfortable with that language here is the equivalent code in C#:-
    Code:
                using (SolidBrush b = new SolidBrush(Color.Blue))
                {
                    DoBrushStuff(b);
                }
    Code:
                SolidBrush b = new SolidBrush(Color.Blue);
    
                try
                {
                    DoBrushStuff(b);
                }
    
                finally
                {
                    if (b is IDisposable)
                    {
                        ((IDisposable)b).Dispose();
                    }
                
                }
    EDIT:

    I forgot to mention that I took some liberties with those examples. For instance there might be some null checking going on and the check for the IDisposable interface could be done by the compiler itself instead of emitting code to do it at run time.

    However, for the purposes of understanding what a Using block really is, it is sufficient. These minor differences wouldn't change the behavior of Using blocks in any significant way so there is no need to be precise. Besides, the minor details could theoretically change between compiler versions but the core ideas would remain the same.
    Last edited by Niya; Feb 16th, 2018 at 01:56 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  16. #456
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Vb6 , the Future, and what I have discovered

    So, when you are using a "Wrapper-Class for a flat-API" from the .NET-framework
    (like e.g. the httpClient - which wraps Socket-APIs and -Handles underneath) you could do this:
    Code:
    using(var client = new HttpClient()) {
        //do something with http client
    }
    Am I right?


    Quote Originally Posted by Niya View Post
    Yes...
    You missed the point I was trying to make Niya (I know already how the using-Block works).

    Sitten already catched the ball quite nicely above, ending with:
    "So help me, if someone designs a VB7 and puts something like the Disposable pattern in it, the club-beating I mentioned before will also be reserved for that person."

    A language (or compiler), which organizes its "automated Memory-deallocations - and destructor-calling" without having to resort
    to a separated (parallel running) GC-instance, is IMO better off (because the whole IDisposable-mess can be avoided from the get go).

    Olaf

  17. #457
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Schmidt View Post
    You missed the point I was trying to make Niya (I know already how the using-Block works).

    Sitten already catched the ball quite nicely above, ending with:
    "So help me, if someone designs a VB7 and puts something like the Disposable pattern in it, the club-beating I mentioned before will also be reserved for that person."

    A language (or compiler), which organizes its "automated Memory-deallocations - and destructor-calling" without having to resort
    to a separated (parallel running) GC-instance, is IMO better off (because the whole IDisposable-mess can be avoided from the get go).

    Olaf
    Well you got me there. I'm with Sitten on this. I'm not too fond of the IDisposable pattern either. The problem I run into quite often is the finalizer running on it's own thread which causes all kinds of chaos when dealing with complicated destruction scenarios. There are so many things you just can't do in a finalizer. I can't recall specifics off hand but I do remember writing classes in the past that had tricky disposal needs and I had to go to war with the finalizer to make them work.

    However, I still prefer the mark and sweep garbage collector over COM's reference counting strategy, the biggest reason being circular references. This one caused me a few headaches in VB6. I tend to write a lot of classes that work that way. Mark and sweep garbage collectors don't require that you care about circular references but reference counting garbage collectors do. It's not a deal breaker for me though. I can work with both types just fine. I just like mark and sweep better.

    As for alternatives for the IDisposable pattern that can work with a mark and sweep collector like the CLR's, I'll let smarter people than me ponder on that. These things aren't really a big deal for me. I'll work with whatever I got.

    It might sound strange but of all memory management strategies, I find manual management, like you would do in C(malloc/free etc) or the Win32 API(GlobalAlloc, HeapAlloc, HeapFree etc) to be the most appealing. It's an outdated mode of thinking, I know but there is something about having full control that makes it attractive to me.
    Last edited by Niya; Feb 16th, 2018 at 09:13 PM.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  18. #458
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Vb6 , the Future, and what I have discovered

    I don't mean to imply that I don't like garbage collection. IDisposable and finalizers are a bad way to have a GC deal with unmanaged code.

    The really good garbage collected languages I use don't have a concept of finalizers, or if they do I haven't ever used it. If you use them to deal with unmanaged things, the onus is on you to keep track of your scope/references and manually call cleanup when it's time. As far as I can tell, this is pretty much how VB6 does it. It doesn't know what an HWND is, it just knows you asked for a Long from an API call. Let that Long fall out of scope and it's gone. The end. In a lot of languages, garbage collection works like that, it's just instead of "gone" happening immediately after going out of scope, it happens "at some point when the GC decides on it".

    So in the end, .NET has the same rules as a language without a GC: if you need to clean up, do so before dropping your last reference to the thing. They tried to give you an escape hatch if your user forgets. Turns out in very complex scenarios, that makes bigger problems than memory leaks. Lesson learned: follow the rules. Sometimes we can't follow those rules, because we have to use some cruddy third-party API that doesn't follow them itself.

    That's not the GC's fault. You can't tell me there haven't been some "interesting" VB6 threads about some vendor-provided COM object that does stupid things that require not following VB6's rules to make it happy. Careless programmers create interesting problems. Then they sell those interesting problems to businesses who have no other choice. That's the "fun" of enterprise development.

    Obj-C lets you opt in to reference-counted garbage collection, most people do unless they have good reason to believe they can outperform it. Part of the Obj-C API design assumes you use an MVC pattern. Views and ViewControllers always have a circular reference to each other. So how's that work? Obj-C has a 'weak' keyword. If you use that as part of your variable declaration, then the variable does NOT add a reference to the reference count. This means you have to be a little more careful about checking for Nil, but that's always "a rule" so I reference previous statements about following them. As far as I can tell, finalization is deterministic in Obj-C.

    .NET has a concept of a WeakReference, but no language makes it a keyword. I think this is because the .NET GC already detects and deals with circular references. That means WeakReference tends to get used for special-cases. It's not a good idea for handling unmanaged things, anyway.

    So don't get me wrong. I like the idea of a GC and many successful modern languages are built with one. You can overtax them and it can become a burden, but computers today are very powerful and we've learned a lot about GC design. Things that used to cause the .NET GC to display visible performance problems are now almost invisible due to both. There are issues like boxing and unboxing that used to be murder for us and now the costs are so trivial we do them without concern. It's not a bad idea to have a GC. Especially since most of your tasks don't involve you directly using unmanaged resources.

    But boy howdy, if you need to work with unmanaged resources, you want determinism. As a developer, you need to have a really good understanding about how and when your stuff gets destroyed. .NET Standard 2.0 allows you to write your own GC and compile that into your programs. I don't doubt we'll see a more deterministic GC by 2019.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  19. #459
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Vb6 , the Future, and what I have discovered

    Also this etch-a-sketch machine was a microcontroller running .NET in 2009. Way earlier than I remembered.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  20. #460
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Vb6 , the Future, and what I have discovered

    That's pretty cool, but didn't you post it in the wrong thread?
    My usual boring signature: Nothing

  21. #461
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Shaggy Hiker View Post
    That's pretty cool, but didn't you post it in the wrong thread?
    I... actually don't know. I think a page or so ago dilettante said something about microcontrollers and there was a bit of discussion about it. There's about 3 different threads with the same kind of stuff going on in them. I swear I looked back and it was there? But it was in between mugs of coffee in the morning so maybe I messed up.

    Anyway, that video crossed my view as I was digging through some really old bookmarks and I honestly didn't think stuff like this was happening until 2013 or later.
    Last edited by Sitten Spynne; Feb 17th, 2018 at 09:10 PM.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  22. #462
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Vb6 , the Future, and what I have discovered

    Yeah, I'm not about to go searching through the various threads, either. I was thinking this made more sense in the thread about things written in .NET, but now that you mention it, I do remember that microcontroller post, and it doesn't seem likely that it was in the other thread.
    My usual boring signature: Nothing

  23. #463
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Vb6 , the Future, and what I have discovered

    Sitten's post was in reference to this post, from a page ago.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  24. #464
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Sitten Spynne View Post
    So in the end, .NET has the same rules as a language without a GC:
    - if you need to clean up, do so before dropping your last reference to the thing.
    No - and that's exactly what I'm trying to explain the whole time...

    When you have a Class-System which is build around RefCounting, then:
    - no GC is needed at all
    - Memory-Cleanups will happen immediately when Class-Instances go out of scope
    - the User of such a Class will have *no* obligation to call a dedicated Cleanup-Routine (to free Class-internal Handles)

    Please look at the following (working) VB6-example (which is using the "old GDI-wrapper-Classes of the RC5"):
    Code:
    Option Explicit
    
    Private Sub Form_Click()
      Dim DIB As cDIB, DC As cDC 'define two Class-Variables with local scope
      
      Set DIB = New_c.DIB(320, 240) 'create the DIB-instance (using a Constructor)
          DIB.Fill vbYellow 'ensure a BackGround-Fill on the complete DIB-area
         
      Set DC = New_c.DC(DIB) 'create a DC-instance (using the Constructor, to select the DIB)
          DC.DrawGradient vbGreen, vbBlue, 0, 0, DIB.dx, 28, True 'draw a Gradient at the top
          DC.SetFont "Times New Roman", 32, True, True, vbRed 'select a Font (bold, italic, red)
          DC.DrawText "Hello World", 0, 0, DIB.dx, DIB.dy, vbCenter, True 'centered Text-Out
          
      Set Me.Picture = DIB.Picture 'flip what was drawn on the DIB to the Form-Picture
    End Sub '<- at this point, the local ClassInstances are dead, and everything (memory, and handles) were destroyed properly already
    Producing this output:


    The above will show no "GDI-Handle-leaking" - and also no "Memory-leaking" (no matter how fast or often you Click on that Form) -
    instead the User can be absolutely sure, that when he leaves the SubRoutine, everything is as it was before (Memory and HandleCount-wise).

    That's how things can work with COM-based "RefCounting wrapper-classes for Flat-APIs".
    (with no obligation on the user of such Wrapper-classes, to call any extra-cleanup-methods).

    With a GC-based system, you cannot acccomplish the same thing (with the same guarantees for "immediateness").

    Olaf

  25. #465
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Vb6 , the Future, and what I have discovered

    i did post about this in a previous post, but didn't get much response.
    right now im coding and i need to create a function that return a number in a "fixed" array, but i can only do so using a string array,
    so right now I do:

    Dim narray() As String
    narray = Split("3, 8, 17, 27, 33, 42, 62, 71, 80, 87, 98, 117, 121, 135, 143, 149, 227, 280, 299", ",")

    and then convert the string into a integer/long.
    so, for the new IDE i would like something like:

    Const narray(19) As Long = [3, 8, 17, 27, 33, 42, 62, 71, 80, 87, 98, 117, 121, 135, 143, 149, 227, 280, 299]
    (or Dim)

    possible right?
    Last edited by baka; Feb 26th, 2018 at 01:10 PM.

  26. #466
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Vb6 , the Future, and what I have discovered

    baka

    Sounds like you may be hankering after the Data statement which had pre VB1.

    >possible right?

    For the time being does...
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    
        Dim a As Variant, i as Integer
        a = Array(3, 8&, 17&, 27&, CStr(33), 42&, 62&, 71&, 80&, 87&, 98&, 117, 121@, 135&, 143&, 149&, 227&, 280&, 299&)
        
       'Just to show data types specified with suffixes in the original data are preserved in the elements of the variant array 
        Debug.Print    
        For i = 0 To UBound(a)
            Debug.Print TypeName(a(i)),
        Next
    
    End Sub
    ... have any appeal

  27. #467
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,598

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by Magic Ink View Post
    baka

    Sounds like you may be hankering after the Data statement which had pre VB1.

    >possible right?

    For the time being does...
    Code:
    Option Explicit
    
    Private Sub Command1_Click()
    
        Dim a As Variant, i as Integer
        a = Array(3, 8&, 17&, 27&, CStr(33), 42&, 62&, 71&, 80&, 87&, 98&, 117, 121@, 135&, 143&, 149&, 227&, 280&, 299&)
        
       'Just to show data types specified with suffixes in the original data are preserved in the elements of the variant array 
        Debug.Print    
        For i = 0 To UBound(a)
            Debug.Print TypeName(a(i)),
        Next
    
    End Sub
    ... have any appeal
    Baka's suggestion implies a strongly typed array, not an array contained within a Variant. An argument can be made that static typing goes a long way in preventing developer errors.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  28. #468
    Frenzied Member
    Join Date
    Mar 2008
    Posts
    1,210

    Re: Vb6 , the Future, and what I have discovered

    For the time being thank you for pointing that out..

  29. #469
    PowerPoster Elroy's Avatar
    Join Date
    Jun 2014
    Location
    Near Nashville TN
    Posts
    9,852

    Re: Vb6 , the Future, and what I have discovered

    I must admit that I do still miss the Data/Read statements. However, I've made the Array() function work quite well when that's called for. As an example, here are some lines in my contemporary code:

    Code:
    
        m_b0dia = Array(-13.567, -43.7777, -35.5221, -25.9772, -16.9931, -19.6683, -33.2858, -42.522, -34.2517, -42.4833, -54.4375, -38.5925, -40.8119, -46.3014, -47.6314, -41.6665, -45.7369, -51.929, -45.8559, -39.5605, -33.7657, -32.281, -31.5797, -32.2816, -25.44, -22.8873, -20.7911, -18.557, -17.5306, -14.3488, -16.6395, -10.6475, -10.0847, -9.646, -5.5, -3.1184, -1.8889, 1.3652, 4.1129, 1.4862, -2.474, -0.415, -0.0497, -1.5833, 1.209, 1.2834, -0.4438, -0.2325, -2.1989, -0.8411, 0.1678, 0.8079, -1.1219, -4.8133, -8.1979, -6.752, -3.566, 1.0387, 1.6962, 1.7174, -1.1808, -1.9286, -0.6762, 0.0177, 1.8242, 3.3864, 1.4518, -0.2228, -1.2686, -1.1771, -1.5905, 1.3907, 5.7059, 12.6597, 14.3993, 17.6818, 11.917, 9.2777, 5.8584, 9.3245, 16.2286, 15.2268, 10.4724, 5.2365, 10.1259, 8.7996, 7.3808, 8.2409, 16.3443, 13.6814, -2.2305, 7.1024, 22.5224, 7.1688, 10.9219, 0.0292, -7.4708, 17.4158, -2.725)
        m_b1dia = Array(0.4118, 0.4741, 0.4425, 0.3556, 0.2916, 0.3203, 0.3986, 0.4632, 0.4233, 0.466, 0.569, 0.5015, 0.5119, 0.5495, 0.5434, 0.4983, 0.5321, 0.586, 0.5356, 0.5025, 0.4575, 0.472, 0.4845, 0.4779, 0.421, 0.4141, 0.3921, 0.3937, 0.3838, 0.3712, 0.3924, 0.3509, 0.3368, 0.3398, 0.3246, 0.3161, 0.3178, 0.3031, 0.2849, 0.295, 0.3229, 0.3217, 0.3277, 0.3439, 0.3277, 0.335, 0.3463, 0.3529, 0.3643, 0.3572, 0.3552, 0.3404, 0.3561, 0.3871, 0.4011, 0.3884, 0.3807, 0.3494, 0.3625, 0.3556, 0.3668, 0.3747, 0.3859, 0.398, 0.381, 0.3667, 0.3836, 0.3835, 0.3885, 0.382, 0.39, 0.3789, 0.3493, 0.3265, 0.3118, 0.2899, 0.3206, 0.3418, 0.3719, 0.3581, 0.3267, 0.3504, 0.3634, 0.4039, 0.3722, 0.3767, 0.366, 0.3742, 0.3376, 0.3408, 0.4491, 0.4266, 0.3231, 0.3913, 0.3914, 0.5124, 0.5394, 0.3737, 0.4042)
        m_b2dia = Array(0.0003, -0.0029, -0.0025, 0.0003, 0.0006, -0.0015, -0.0021, -0.0051, -0.0055, -0.0072, -0.0112, -0.0094, -0.0092, -0.0106, -0.0102, -0.0073, -0.008, -0.0101, -0.0086, -0.0082, -0.0075, -0.0081, -0.0091, -0.0097, -0.007, -0.0056, -0.0042, -0.0045, -0.0047, -0.004, -0.0047, -0.0034, -0.0033, -0.0036, -0.003, -0.0025, -0.0027, -0.002, -0.0018, -0.0018, -0.0028, -0.0029, -0.0029, -0.003, -0.0027, -0.0025, -0.0031, -0.0033, -0.0037, -0.004, -0.0038, -0.0029, -0.0036, -0.0049, -0.0058, -0.0055, -0.005, -0.0037, -0.0033, -0.0029, -0.0036, -0.0042, -0.0052, -0.006, -0.0045, -0.0046, -0.0047, -0.0048, -0.0049, -0.0052, -0.0063, -0.006, -0.0054, -0.0048, -0.0037, -0.0031, -0.0046, -0.0056, -0.0073, -0.0073, -0.0058, -0.0059, -0.0056, -0.0071, -0.0063, -0.006, -0.0058, -0.008, -0.0067, -0.0062, -0.0095, -0.0107, -0.008, -0.0079, -0.0095, -0.0137, -0.0152, -0.0096, -0.0133)
        m_b3dia = Array(-0.0263, -0.0496, -0.0428, -0.0543, -0.0481, -0.0388, -0.0592, -0.0392, -0.0269, -0.0191, -0.0014, 0.0059, 0.0039, 0.0106, 0.0067, -0.0149, -0.0146, -0.0013, -0.0063, -0.003, -0.0012, 0.0063, 0.0143, 0.0203, 0.0038, -0.0066, -0.015, -0.0121, -0.009, -0.0129, -0.0114, -0.0169, -0.0182, -0.0141, -0.0129, -0.0137, -0.01, -0.0117, -0.0081, -0.0113, -0.0094, -0.0082, -0.0071, -0.0061, -0.0052, -0.0086, -0.0075, -0.0065, -0.0061, -0.0005, -0.0004, -0.0096, -0.0078, -0.0019, 0.0028, 0.0002, -0.0007, -0.0064, -0.0098, -0.0144, -0.0124, -0.0079, 0.0017, 0.0074, -0.0055, -0.0044, -0.0045, -0.0063, -0.0053, -0.0022, 0.0071, 0.0072, 0.0068, 0.0144, 0.0089, 0.0095, 0.0186, 0.0253, 0.0382, 0.0413, 0.0385, 0.0373, 0.0276, 0.0317, 0.0273, 0.0209, 0.0184, 0.033, 0.028, 0.0239, 0.0277, 0.0507, 0.0497, 0.0285, 0.0458, 0.0821, 0.0752, 0.0478, 0.0238)
        m_b4dia = Array(0.0507, 0.1518, 0.1269, 0.1499, 0.1416, 0.1406, 0.2053, 0.1567, 0.1286, 0.1105, 0.0879, 0.0528, 0.0554, 0.0468, 0.0518, 0.0964, 0.1016, 0.0747, 0.0786, 0.0687, 0.0596, 0.0419, 0.0265, 0.0104, 0.0396, 0.0583, 0.0686, 0.0655, 0.0598, 0.0679, 0.0678, 0.0752, 0.08, 0.0709, 0.0635, 0.0596, 0.0505, 0.0496, 0.038, 0.0461, 0.0487, 0.0472, 0.0414, 0.0371, 0.0323, 0.0415, 0.0435, 0.0434, 0.0459, 0.0305, 0.0275, 0.0477, 0.0484, 0.0409, 0.0321, 0.0371, 0.0371, 0.0437, 0.0505, 0.0602, 0.0586, 0.0509, 0.0314, 0.0231, 0.0517, 0.0516, 0.0515, 0.0572, 0.0531, 0.0473, 0.0279, 0.0262, 0.0244, -0.0045, -0.0004, -0.0089, -0.0278, -0.0412, -0.0675, -0.0754, -0.0835, -0.0777, -0.0497, -0.0486, -0.0379, -0.0216, -0.0173, -0.0361, -0.0305, -0.0268, -0.0118, -0.0701, -0.0852, -0.027, -0.0634, -0.1555, -0.1166, -0.0772, 0.0586)
    
    They're not constants, but I don't change them once they're set. So, in effect, they are.
    Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.

  30. #470
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,721

    Re: Vb6 , the Future, and what I have discovered

    This is about the new IDE, my suggestion is to make it more like JAVA/C, where we can declare the array and values in the same line.
    The "Array" function need the variable to be a variant, in my example it need to be a string, also, in both cases, we can't just declare it outside any function, it need to be initialized somewhere. My post is not intended for asking for help, to get tons of suggestions, no my post is for the new IDE and what I would like to have.
    also, the use of Split make it also favorable as I can have the content in a CONST string at the top of the module with all the values needed.
    of course to save space i can simply add the string directly inside the SPLIT.

  31. #471
    Junior Member
    Join Date
    Jan 2011
    Posts
    20

    Re: Vb6 , the Future, and what I have discovered

    On February 5th, Olaf stated:
    "And as for "wellknown methods" - you perhaps mean "good old GDI" - which you invested weeks to learn (when you were a Newbie) -
    though you seem not to be willing to invest even a day or two into learning the Cairo-DrawingMethods...
    (which are all explained in detail in a large Tutorial, which you and GJCurchward probably never looked at)."

    I'll quickly gloss over the fact that I spent most of two weeks trying to pull out of the Cairo Tutorials, the correct way to achieve the behaviour which I need, then spent nearly three days on a demo program I sent to Olaf, showing something like the behaviour I need, as far as it was possible with VB6 alone. I accept that I need to master some unfamiliar concepts, being a relative newbie with the level of graphics for which I need a graphics library. I invested rather more than 'a day or two', so please don't patronize me.

    I arrived in this thread not because I am trying to do 'something for the community', as I often see written here, but because I'm searching for practical ways to solve my VB6 problems. I think I'm a member of 'the community', so please - if you can explain how to approach something, please do so without troubling me with whether something is Open Source, or compilable IDEs, or the long-term future of VB6.

    I have a need to display in the same DC, images representing many kinds of real-world object. The images are held on a server machine, which communicates with its clients using Sockets, therefore it's already awkward to get an image sent to a client when required; I believe the correct approach is to convert .BMP files to byte streams at the server, to be reassembled on rendering at the client end.

    The vbRichClient5 library appears to allow this. There is a method 'AddImage' on the cCairoSurface object, and I can see that it has an argument of type 'FileOrByteArray'. The byte array looks like the way to go. What does that array look like? How do I create it in the first place, and how do I then access individual pixels (since I will have some pixel-level image manipulation to perform)?

    In all of the Cairo tutorials, AddImage is only used with a file. I would like to see a working example of its use with a byte array, please.

  32. #472
    PowerPoster
    Join Date
    Sep 2012
    Posts
    2,083

    Re: Vb6 , the Future, and what I have discovered

    Hi GJChurchward, why don't you post a new thread to discuss the issues you need to solve?

    VBForums search tool is extremely bad, so you need to carefully review all of Olaf's comments, you can find the answer.

    The following two threads may be useful to you:

    http://www.vbforums.com/showthread.p...ob-Sqlite3-vb6

    http://www.vbforums.com/showthread.p...o-a-byte-array
    Last edited by dreammanor; Mar 5th, 2018 at 11:23 PM.

  33. #473
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    38,988

    Re: Vb6 , the Future, and what I have discovered

    VBForums search is kind of limited, but Google search is not so much. Some members find it easier to use Google to search this site rather than the search tools here.
    My usual boring signature: Nothing

  34. #474
    PowerPoster
    Join Date
    Jun 2013
    Posts
    7,219

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by GJChurchward View Post
    There is a method 'AddImage' on the cCairoSurface object, and I can see that it has an argument of type 'FileOrByteArray'.
    To correct the sentence above (for the sake of precision) - it is the cImageList-Object you mean,
    and its AddImage-Method has a (Variant)Parameter: FileNameOrByteArray

    Below is some TestCode for you, which is filling that Parameter over a similar-named Variable:
    Code:
    Private Sub Form_Load()
      Dim FileNameOrByteArray As Variant
          FileNameOrByteArray = "c:\temp\test.jpg"
     
      Cairo.ImageList.AddImage "ImgKey1", FileNameOrByteArray
      
      'get the stored Image from the Collection(By Key) and make it the Form-Picture
      Set Me.Picture = Cairo.ImageList("ImgKey1").Picture
    End Sub
    Quote Originally Posted by GJChurchward View Post
    The byte array looks like the way to go.
    What does that array look like?
    How do I create it in the first place, ...
    The Array should "look like" a normal VB6-ByteArray-Type - and since the context (due to your usage of an ImageResources-Collection) is obviously:
    - Loading (decoding) of Image-Content (per FileName or ByteArray - and "storing it under a given StringKey for later re-usage")
    ... a first educated guess might encourage you, to make an attempt with "a VB6-ByteArray of the plain ImageFile-Content".

    e.g. using the appropriate RC5-Helper-Function for that via New_c.FSO.ReadByteContent(...)


    Note the return-value-type of the above Helper-Function, which says " As Byte()"

    So, the "ByteArray-Content" in this case, is the (usually compressed) "original content of the Image, as represented on Disk"
    (no matter, if you transfer such "compressed Image-content" over sockets - or reading such Image-Content from DB-Blob-Fields, or whatever).

    Quote Originally Posted by GJChurchward View Post
    ...and how do I then access individual pixels (since I will have some pixel-level image manipulation to perform)?
    Accessing individual pixels of a given Image, only makes sense - *after* you decoded (decompressed) the "Raw-Image-Content-Bytes" into a "DIB-like Image-Container".
    (e.g. the code shown above, already does that "decoding-stage" for you, the results then being available App-wide over: Cairo.ImageList("MyImgKey")
    So, the Cairo.Imagelist can hand out a cCairoSurface-Container to you (which in the RC5 is always holding the decoded Image in a "32Bit-BGRA-DIB-with-Alpha").

    I've posted an article about Pixel-access/manipulation on Cairo-ImageSurfaces a while ago into the codebank:
    http://www.vbforums.com/showthread.p...airo-Surfaces)

    HTH - but as pointed out by dreammanor already - better to ask specific questions in their own threads.

    Olaf

  35. #475
    Junior Member
    Join Date
    Oct 2013
    Posts
    16

    Re: Vb6 , the Future, and what I have discovered

    Been lurking here (and learning alot) for a few years, guess I had to post eventually.


    Here's some suggestions for Olaf's new VB (some already mentioned previously) of things I have found (at times) frustratingly missing in VB6.


    'Missing' numeric data types:

    Signed byte
    Unsigned Integer
    Unsigned Long
    Signed/unsigned 64 bit long


    Operators:

    Bitwise operators/functions such as a<<2 or a shl 2

    Unary and assignment operators ++, --, +=, *=, etc
    Keeping in mind the 'basic' aspect of the language, perhaps unary operators should only be allowed in isolation (on a line by itself). Although I do like C/C++ code, I have seen far too many instances of post/pre inc/decrement functions that while they may shorten the line of code certainly don't make it more readable (nor give any advantage with modern compilers afaik).


    Allow ParamArray with specified types, eg:
    Sub Test1(ParamArray a() as Long)
    Sub Test2(ParamArray a() as string)


    Arrays:

    A function (perhaps IsNull) to return true for an unassigned array. Alternatively a function to return the number of elements in an array (0 for undimmed)

    Use {} for assigning data sets.

    Dim a() As Long = { 1,2,3,4,5,6,7,8,9 } ' also for Const
    Dim b(1 to 9) As Long = { 1,2,3,4,5,6,7,8,9 } ' also for Const
    Dim c(,) As Long = { {1,2,3},{4,5,6},{7,8,9} } ' also for Const

    Dim d(,): ReDim d(,) = { {1,2,3},{4,5,6},{7,8,9} }

    Dont force use of line continuation within bracketed {} data sets
    Dim a() As Long = _
    {
    1,2,3,4,5,6,7,8,9,0,
    1,2,3,4,5,6,7,8,9,0,
    1,2,3,4,5,6,7,8,9,0,
    1,2,3,4,5,6,7,8,9,0
    }


    In the 'nice to have' list...

    * Multithreading

    * Array copy/assignment. Something like:

    a{} = { 1,2,3,4,5,6,7,8,9 } ' copy to a from first element (might be partial fill)
    a{3} = { 1,2,3 } ' copy to a, starting from element 3

    a{} = b{} 'Copy to a from b, all elements in b (might be partial fill of a). Error if b has more elements than a.
    a{3} = b{5} 'Copy to a (starting element 3) from b (starting element 5) until end of array b
    a{3} = b{5:7} 'Copy to a (starting element 3) from b (from element 5 to 7)


    Best of luck to Olaf & anyone who ends up helping him to complete the project. I don't have the skillset to offer coding help for this sort of thing, but do have the time - so when it gets to the debug/testing stage if you're looking for testers I'd be happy to help (Background in Fortran, C & C++. Effectively working in VB only since '98).

  36. #476
    Junior Member
    Join Date
    Jan 2011
    Posts
    20

    Re: Vb6 , the Future, and what I have discovered

    Thank you dreammanor, and Olaf for your replies on March 6 and 7. I've only just seen them - for some reason, my usual notification of a reply in the forum has not arrived... :-(

    I will indeed prepare some specific queries about my challenges trying to get these graphics to work, and I will include the words 'vbRichClient5.dll' and 'Cairo' in the subject. I expect you will readily see that I have posted. I do need your input please, Olaf - since you are the author of the tools I must use, and are therefore the definitive authority on the subject.

  37. #477
    Registered User
    Join Date
    Oct 2018
    Posts
    4

    Re: Vb6 , the Future, and what I have discovered

    Hello VB 6 Gurus - I am new to this forum, i have question . I have a small application developed on VB6 , recently i have migrated DB from ms access to MySql . I would like to have the advice on how to use this as a web application with the same base code ?

  38. #478
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by vmadala View Post
    Hello VB 6 Gurus - I am new to this forum, i have question . I have a small application developed on VB6 , recently i have migrated DB from ms access to MySql . I would like to have the advice on how to use this as a web application with the same base code ?
    Step 1 - post this as a new thread rather than taking it onto an existing thread that has nothing to do with your issue. I'll ask the mods to move your post off to it's own thread.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  39. #479
    Registered User
    Join Date
    Oct 2018
    Posts
    4

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by techgnome View Post
    Step 1 - post this as a new thread rather than taking it onto an existing thread that has nothing to do with your issue. I'll ask the mods to move your post off to it's own thread.

    -tg
    Thanks , let me do it or if admins create a new thread i am good with it. As a new member, I am not sure if i have access to it.

  40. #480
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,531

    Re: Vb6 , the Future, and what I have discovered

    Quote Originally Posted by vmadala View Post
    Thanks , let me do it or if admins create a new thread i am good with it. As a new member, I am not sure if i have access to it.
    Only the mods have that power, so let them, do it.
    To be honest, I'm surprised it hasn't been done yet, they're usually pretty good at responding to such requests.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Page 12 of 18 FirstFirst ... 29101112131415 ... LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width