Page 2 of 4 FirstFirst 1234 LastLast
Results 41 to 80 of 138

Thread: Programming FAQ -- show off your cool tips here!

  1. #41
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395
    BrianHawley - you made it quite clear - and be honest I can not
    understand the fass about this copyright here in a Forum. This
    does not include whole pieces of Software. I put a copyright on
    my SW as well.

    But for snipplets or small routines here in the forum I think we
    should not be so picky.

    As you mentioned If I realy would develop a new (and deffenitly the best) sorting algo. I think I would not release the code before
    I have the proper copyright on it.


    Interesting is actualy the point you mentioned that MS has allready
    testes most thinks - therfore the copyright should actually with them. So if we go this rouad further actually everey peace of SW
    written with there development tools are belonging to them????

  2. #42
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    Originally posted by Bongo
    So if we go this rouad further actually everey peace of SW
    written with there development tools are belonging to them????
    I would not go that far. But if you write a trivial routine that just calls a MS API, it's hardly worth trying to copyright it. The main benefit of the code is to execute the API, and that's all MS code, not yours - so your copyright is trivial.

    A lawyer friend of mine has just read my earlier posting and says I'm not quite right. In a trivial copyright case, the court may find that you DO technically own the copyright on the code, but they will only give you small damages (maybe one penny) to punish you for wasting everybody's time, even though you are technically in the right.
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  3. #43
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395
    Originally posted by BrianHawley


    In a trivial copyright case, the court may find that you DO technically own the copyright on the code, but they will only give you small damages (maybe one penny) to punish you for wasting everybody's time, even though you are technically in the right.
    I like this scenario.

    ok in the end of the day most of my work is owned by my clients (contracter) and the few Apps I wrote are so specific so there are not on the market for sell.

  4. #44
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    Originally posted by Bongo


    I like this scenario.

    ok in the end of the day most of my work is owned by my clients (contracter) and the few Apps I wrote are so specific so there are not on the market for sell.
    What can I say? Life's a bummer.

    Better knock it off with this discussion or we will be in trouble for thread degeneration.
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  5. #45
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    Let's not tied by all these copyright stuffs.
    Use it freely. What's more this is a tips thread.
    We came here to learn new stuffs.
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  6. #46

    Thread Starter
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    ROFL this thread got WAY off topic

    Back to the FAQ. (gee what a [corny] rhyme! wow!)


    I like the idea of letting members maintain the FAQ, but I would have to trust the moderators explicitly before I let them fark around on me web site

    If anyone is willing to be a guinea pig -- erm, volunteer -- for the moderating position, just speak up.

    I know you kicked the idea around earlier in this thread, but if you are serious about moderating the FAQ, please PM or email me using the coooool little buttons below this post.

    There are no perks for moderating the FAQ, except you might get a little fame and glory by having your name on the Moderators list. No cars, no cash, no women, nothing -- those are all for me (j/k)



    Also someone asked earlier how much it costs to register a copyright. Technically, $25 US per entry. Thats per entry tho -- if you want to copy code AND interface, you have to pay for 2 entries (last time I checked.) However, if you copyright 30 different windows for your interface, its only one entry as long as your screeen shots are all together in the package.

    Of course, you also have to pay for shipping/postage, for the CDs/floppies that your copyrighted material is on (so they can test it out and never send it back) and all that good stuff. But its worth it -- for $200 at the MOST you can have the full legal rights to sue the living crap out of anyone that violates your copyright




    Anyway, I am still on my @%$#@^%$#^@%$ trip so I won't be able to do anything on the site, but as soon as I get back to my beloved workstation I will get that moderation stuff going. Priviledged users will be able to:

    Post news items on the site
    Post items to the FAQ
    other cool stuff later in life


    The main problem here is that I will have to reconfigure the site to quit storing HTML and start storing the FAQ in the database. I suppose I was a bit of an idiot for not doing that at the very beginning, but oh well

    Look for all these updates ... uh.... sometime. I have 2 days to do those changes (which will be busy as heck) and then ANOTHER trip, this time longer. Crap. Hopefully I will have more free time on the next one...

    Better go before my timesheet starts looking suspicious
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  7. #47
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Talking There's a slug sliming up my leg. GET IT OFF!

    Originally posted by agent
    haven't read through all the posts, but...

    this code
    Code:
    If a = "Hello" Then
        b = "Hi"
    Else
        b = "Bye"
    End If
    has the same effect as
    Code:
    b = Iif(a = "Hello", "Hi", "Bye)
    Agreed, but the IIf statement is 3 times slower! Not recommended if you require your program to be as fast as possible. It's also the same as:

    VB Code:
    1. Select Case a
    2.    Case "Hello"
    3.       b = "Hi!"
    4.    Case Else
    5.       b = "Bye"
    6. End Select

    But again, this is slower than the If Then command.
    Here's a bench test program I wrote for Vb to work out which commands are the fastest...You will have to replace the Connection string for ADO if you want to bench test it

    I appologies for the programming code, I was very hungover, tired and had someone pestering me while I wrote it, so yes I know, it's bad, but it still gives you an idea of speeds.

  8. #48
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344
    Originally posted by mlewis
    ROFL this thread got WAY off topic

    Back to the FAQ. (gee what a [corny] rhyme! wow!)


    I like the idea of letting members maintain the FAQ, but I would have to trust the moderators explicitly before I let them fark around on me web site

    If anyone is willing to be a guinea pig -- erm, volunteer -- for the moderating position, just speak up.

    I know you kicked the idea around earlier in this thread, but if you are serious about moderating the FAQ, please PM or email me using the coooool little buttons below this post.

    There are no perks for moderating the FAQ, except you might get a little fame and glory by having your name on the Moderators list. No cars, no cash, no women, nothing -- those are all for me (j/k)



    Also someone asked earlier how much it costs to register a copyright. Technically, $25 US per entry. Thats per entry tho -- if you want to copy code AND interface, you have to pay for 2 entries (last time I checked.) However, if you copyright 30 different windows for your interface, its only one entry as long as your screeen shots are all together in the package.

    Of course, you also have to pay for shipping/postage, for the CDs/floppies that your copyrighted material is on (so they can test it out and never send it back) and all that good stuff. But its worth it -- for $200 at the MOST you can have the full legal rights to sue the living crap out of anyone that violates your copyright




    Anyway, I am still on my @%$#@^%$#^@%$ trip so I won't be able to do anything on the site, but as soon as I get back to my beloved workstation I will get that moderation stuff going. Priviledged users will be able to:

    Post news items on the site
    Post items to the FAQ
    other cool stuff later in life


    The main problem here is that I will have to reconfigure the site to quit storing HTML and start storing the FAQ in the database. I suppose I was a bit of an idiot for not doing that at the very beginning, but oh well

    Look for all these updates ... uh.... sometime. I have 2 days to do those changes (which will be busy as heck) and then ANOTHER trip, this time longer. Crap. Hopefully I will have more free time on the next one...

    Better go before my timesheet starts looking suspicious
    Yeah ok I be a guinea pig for your site. Thanx for the info on the copright rights.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  9. #49
    Frenzied Member nishantp's Avatar
    Join Date
    Jan 2001
    Location
    Where you least expect me to be
    Posts
    1,375
    I thought this was really really cool. its a text box with enhanced capabilities because of a class. Could save people a lot of hassle.

    http://www.planet-source-code.com/vb...31890&lngWId=1
    You just proved that sig advertisements work.

  10. #50
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629

    Remove recent files from vb-ide

    Remove recent files from vb-ide

    Open RegEdit And delete all values In:
    HKEY_CURRENT_USER\Software\Microsoft\Visual Basic\6.0\RecentFiles
    -= a peet post =-

  11. #51
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    I would like to share my vb's source codes gathered from
    everywhere - vbworld,PSC,... with others

    It's categorized. And every code is seperated by 4 lines
    And every code has a remark on top to tell what it does

    Later on I'll post source on DirectX7 and DirectX8...

    Hope it helps.
    Attached Files Attached Files
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  12. #52
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    How about some .net stuff?

    All these VB6 tips are going to be gathering dust soon.

    (Stands back and waits to be flamed)
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  13. #53
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    Nope! I actually dont use .NET and wont forever!(Er...Perhaps
    I may have exception later when XP is really popular and when
    I get new PC:P120Mhz cant use XP!

    The VB tips I posted does has lots of advance cool tips!
    If nobody d/l it it's fine, I'll delete the post rightaway!
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  14. #54
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    Originally posted by jian2587
    Nope! I actually dont use .NET and wont forever!(Er...Perhaps
    I may have exception later when XP is really popular and when
    I get new PC:P120Mhz cant use XP!

    The VB tips I posted does has lots of advance cool tips!
    If nobody d/l it it's fine, I'll delete the post rightaway!
    Hey, don't take it too seriously. I meant the whole thread, not just your last post.

    I'm just trying to get more people interested in .net.

    I agree that VB6 wil be around for a long time, because of hardware limitations if nothing else. But .net WILL take over at some point (how many people are still using vb4?) and we should all start getting ready as soon as we can.

    Also a lot of VB6 tips also work in .net with a few small changes.

    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  15. #55
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    Same to you too, pls dont take so seriously on my previous
    post. I just put a couplar of !...

    I'll stick to VB6. Unless .NET is really popular.
    Hey,BTW, I dont know why everybody hates Microsoft,
    and yet use their products, it looks like everybody
    desperated...Me too, I use their products, just because:
    1.Most popular PC games platform
    2.Most popular software development target platform
    3.Most users use.
    4.Get it for A few dollars(pirated) :just kidding
    5.Most familiar
    6.Most unstable OS ever used(I like the BSOD and illegal
    operation ,I've chance to hit my CPU like a mad cow
    7.Compatibilty with others
    (Or is it others try to compatible with it?!!)
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  16. #56
    Addicted Member E-Link's Avatar
    Join Date
    Nov 2001
    Location
    INA
    Posts
    242

    InputBox with Password Characters

    This code shows a simple way of 'hooking' modal windows (MsgBox or InputBox) and changing their behavior.

    VB Code:
    1. 'PUT BELOW DECLARATIONS IN A .BAS MODULE
    2.  
    3. Option Explicit
    4.  
    5. Private Declare Function FindWindow Lib "user32" Alias _
    6.    "FindWindowA" (ByVal lpClassName As String, _
    7.    ByVal lpWindowName As String) As Long
    8.  
    9. Private Declare Function FindWindowEx Lib "user32" Alias _
    10.   "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
    11.    ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    12.    
    13. Public Declare Function SetTimer& Lib "user32" _
    14.   (ByVal hwnd&, ByVal nIDEvent&, ByVal uElapse&, ByVal _
    15.    lpTimerFunc&)
    16.  
    17. Private Declare Function KillTimer& Lib "user32" _
    18.   (ByVal hwnd&, ByVal nIDEvent&)
    19.  
    20. Private Declare Function SendMessage Lib "user32" Alias _
    21.     "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    22.     ByVal wParam As Long, lParam As Any) As Long
    23.  
    24. Const EM_SETPASSWORDCHAR = &HCC
    25. Public Const NV_INPUTBOX As Long = &H5000&
    26.  
    27. Public Sub TimerProc(ByVal hwnd&, ByVal uMsg&, _
    28.    ByVal idEvent&, ByVal dwTime&)
    29.  
    30.     Dim EditHwnd As Long
    31.  
    32. ' CHANGE APP.TITLE TO YOUR INPUT BOX TITLE.
    33.  
    34.     EditHwnd = FindWindowEx(FindWindow("#32770", App.Title), _
    35.        0, "Edit", "")
    36.  
    37.     Call SendMessage(EditHwnd, EM_SETPASSWORDCHAR, Asc("*"), 0)
    38.     KillTimer hwnd, idEvent
    39. End Sub
    40.  
    41. 'THIS IS HOW TO USE THE CODE FROM WITHIN A FORM
    42.  
    43. Private Sub Command1_Click()
    44.   Dim ret As String
    45.   SetTimer hwnd, NV_INPUTBOX, 10, AddressOf TimerProc
    46.   ret = InputBox("Enter Password")
    47. End Sub

  17. #57

    Thread Starter
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Nice! I'll post that as soon as I get a chance!
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  18. #58
    Addicted Member E-Link's Avatar
    Join Date
    Nov 2001
    Location
    INA
    Posts
    242

    Display Windows Background Wallpaper on Form

    this code will show BackGround Wallpaper on Form
    VB Code:
    1. Private Declare Function PaintDesktop Lib "user32" _
    2. (ByVal hdc As Long) As Long
    3.  
    4.  
    5.  
    6. Private Sub Command1_Click()
    7. PaintDesktop Form1.hdc
    8.  
    9. End Sub

  19. #59
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796

    Lightbulb Get CPU Serial Number (.net)

    This is a .net function that returns the CPU serial number.

    Good for security and activation routines that need to ID the PC.

    Not all CPU's will do this, so you may need to fall back to a MAC number. (Code available to do this. Just ask.)

    Not tested much on a range of PC's and OS's, so I would value any comments.

    I'm also fairly new to .net, so feel free to point out any errors or missed optimisations.

    VB Code:
    1. '--------------------------------
    2. 'This is vb.net code. It will not work with vb6
    3. 'or earlier.
    4. '--------------------------------
    5.  
    6. Option Strict On
    7.  
    8. Imports System.management
    9. '--------------------------------
    10. 'If System.management (above) is underlined in blue, then you need
    11. 'to add it to the project references. Click on Project, Add Reference
    12. 'Click on the .NET tab, then select System.management from the table.
    13. 'Click on Select then OK.
    14. '--------------------------------
    15.  
    16. Module Module1
    17.  
    18.  
    19.   Function GetProcessorUniqueID() As String
    20.  
    21.     'PURPOSE: This function returns the UniqueID of
    22.     '         the processor. (The serial number of the
    23.     '         CPU.) It is useful for software activation
    24.     '         and protection routines that need to uniquely
    25.     '         identify a processor. Note that not all
    26.     '         processors return this number, so you may need
    27.     '         to fallback to a network card MAC number or
    28.     '         other unique identifier. But this is the best
    29.     '         thing to use, if the processor provides it.
    30.     '
    31.     '         Quickly hacked together by Brian Hawley
    32.     '         and hardly tested at all. Could probably use
    33.     '         a lot of improvement and testing. Any suggestions,
    34.     '         flaming or praise to VB Q & A on [url]www.vbforums.com[/url]
    35.     '         or to [email][email protected][/email]
    36.     '
    37.     '         Note that Win32_Processor/UniqueID is only
    38.     '         one example of a whole load of stuff available in
    39.     '         System.management. It's worth exploring.
    40.  
    41.     Dim mc As ManagementClass
    42.     Dim moc As ManagementObjectCollection
    43.     Dim mo As ManagementObject
    44.     Dim UniqueIDs As String()
    45.  
    46.     mc = New ManagementClass("Win32_Processor") 'Create the management class
    47.     moc = mc.GetInstances()    'Get all the instances. (May be more than one CPU)
    48.     For Each mo In moc    'Check each one
    49.  
    50.       'Increase the size of the array as required.
    51.       '(Yes, I know there is a better way, but I wanted to play
    52.       'with Try Catch.)
    53.       Try
    54.         ReDim Preserve UniqueIDs(UBound(UniqueIDs) + 1)
    55.       Catch
    56.         ReDim UniqueIDs(0)
    57.       End Try
    58.  
    59.       'Stick the result in the array
    60.       UniqueIDs(UBound(UniqueIDs)) = Convert.ToString(mo.Item("UniqueId"))
    61.  
    62.       mo.Dispose()    ' Not sure if I need this, but it can`t hurt.
    63.  
    64.     Next
    65.  
    66.     'Not that UniqueIDsis an array as there may be more than one processor.
    67.     'We only return the first element here, which is the first processor,
    68.     'but there could be several (if you or your client are rich).
    69.  
    70.     Return UniqueIDs(0)
    71.  
    72.     End Function
    73.  
    74. End Module
    Last edited by BrianHawley; Feb 21st, 2002 at 03:04 AM.
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  20. #60
    Frenzied Member sebs's Avatar
    Join Date
    Sep 2000
    Location
    Aylmer,Qc
    Posts
    1,606
    It's kind a weird that there's 2 thread almost the same!!

    But anyway, i post it there and i might as well do it here too:

    for a score for example, you want it to be

    0000009845

    just do


    Right("0000000000" & yourScore,10)

    see the above would be

    00000000009845

    so 0000 will be droped!!

  21. #61
    Member
    Join Date
    Sep 2001
    Location
    Pune,India
    Posts
    37

    Cool

    This might sound amateurish,but i'm writing it anyway.

    To set the font and font size of all controls on a form to values other then the default values, change the font and font size of the form itself(instead of changing it for every control). Any control placed on the form now will have the form's font and font size
    Smoking Kills Slowly!!!!!!!!...........So who's in HURRY????????

  22. #62
    Bouncy Member darre1's Avatar
    Join Date
    May 2001
    Location
    Peterborough, UK
    Posts
    3,828

    Thumbs up

    Originally posted by yak77
    This might sound amateurish,but i'm writing it anyway.

    To set the font and font size of all controls on a form to values other then the default values, change the font and font size of the form itself(instead of changing it for every control). Any control placed on the form now will have the form's font and font size
    cool
    Confucious say, "Man standing naked in biscuit barrel not necessarily ****ing crackers."

    Don't forget to format your code in your posts

  23. #63

    Thread Starter
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Actually that's a very useful trick that most programmer's aren't aware of. It will make a good addition to the FAQ
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  24. #64
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344
    Originally posted by mlewis
    Actually that's a very useful trick that most programmer's aren't aware of. It will make a good addition to the FAQ
    I found it out by playing with the controls and forms one day.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  25. #65
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Someone Might find this usefull.


    This is a function i wrote to return a random file from the Directory Given.




    VB Code:
    1. Private Function ReturnRandomFile(Directory As String) As String
    2. Dim i As Integer, File As String
    3. a = Mid(Directory, Len(Directory), 1)
    4. If a <> "\" Then Directory = Directory & "\"
    5.  File = Dir$(Directory, vbDirectory)
    6. Do While File <> ""
    7. DoEvents
    8. i = i + 1
    9. File = Dir$
    10. Loop
    11.  
    12. Randomize
    13. x = Int(i * Rnd) + 1
    14. i = 0
    15.  
    16. File = Dir$(Directory, vbDirectory)
    17. Do While File <> ""
    18. i = i + 1
    19. If i >= x Then Exit Do
    20. File = Dir$
    21. ReturnRandomFile = Directory & "\" & File
    22. Loop
    23. End Function


    use it like this

    Text1 = ReturnRandomFile("C:\Windows")

    Or if you were using it toput random pictures in a picture box you would do this.

    Picture1.Picture =LoadPicture(ReturnRandomFile("C:\MyPics"))
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  26. #66
    Junior Member
    Join Date
    Jan 2002
    Location
    Delhi, India
    Posts
    16

    Arrow FAQ into a file that can be updated weekly.

    Nice tips, but tips can suits everyone more if all this tips are copied into a file .doc or .txt form in zip format and re post it. No one have time to go through all 14 pages. With Index is better one.

    I usually copy some tips or solution to a particular problems into a word file and refer it later if I encounter that problems.

    Any suggestions guys / gals.

  27. #67
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344
    Originally posted by srvb
    Nice tips, but tips can suits everyone more if all this tips are copied into a file .doc or .txt form in zip format and re post it. No one have time to go through all 14 pages. With Index is better one.

    I usually copy some tips or solution to a particular problems into a word file and refer it later if I encounter that problems.

    Any suggestions guys / gals.
    You can't copy the FAQ because you don't have Mr. Lewis promission to do so.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  28. #68
    Junior Member
    Join Date
    Jan 2002
    Location
    Delhi, India
    Posts
    16
    Originally posted by Nightwalker83


    You can't copy the FAQ because you don't have Mr. Lewis promission to do so.
    I mean the re-modification of this post so it is naturally directed to mlewis. And request suggestions from other viewers.

  29. #69
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    How's my vb_src.zip?
    The files are in .diz file.
    Just use the folder options to make it be able to displayed
    using notepad.
    Are my tips good?
    Should I make a database program and put all these nice tips
    into it? So searching for it would be easy.
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  30. #70
    Fanatic Member BrianHawley's Avatar
    Join Date
    Aug 2001
    Location
    Saudi Arabia
    Posts
    796
    Originally posted by Arc
    [B]...This is a function i wrote to return a random file from the Directory Given....
    Maybe evil is in the eye of the beholder, but is there any reason to retrieve a random file name, except for a trojan or virus?

    Does Arc have a Dark Side?
    Brian
    (Fighting with the RightToLeft bugs in VS 2005)

  31. #71

    Thread Starter
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    Well, there are several uses for getting a random file. Like someone mentioned above, if you want to load a random picture file from a given folder, that code is highly useful. It also works well for other cases where you need to randomly select something that for some reason needs to be stored in a separate file.


    Regarding the FAQ: the code in the FAQ is provided free of charge. Users may copy, use, modify, and/or redistribute the code portion of the FAQ. All other materials are technically mine, and I wouldn't appreciate people copying things that I wrote (e.g. tutorials on file I/O).

    I will be adding a copyright notice to the FAQ soon, to alert people to this fact.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  32. #72
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Here is a Sub i wrote that will Fade the Background of any control with an hDC property. Such as Forms, PictureBoxes etc... Will fade either Vertically or horizontaly using any 2 RGB colors you specify. Paste all this into a Module.

    VB Code:
    1. Public Declare Function GradientFillRect Lib "msimg32" Alias "GradientFill" (ByVal hdc As Long, pVertex As TRIVERTEX, ByVal dwNumVertex As Long, pMesh As GRADIENT_RECT, ByVal dwNumMesh As Long, ByVal dwMode As Long) As Long
    2. Public Declare Function SetRect Lib "user32" (lpRect As RECT, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
    3. Public Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
    4. Public Type TRIVERTEX
    5.             X As Long
    6.             Y As Long
    7.             R As Integer
    8.             G As Integer
    9.             B As Integer
    10.             Alpha As Integer
    11. End Type
    12. Type LOGBRUSH
    13.     lbStyle As Long
    14.     lbColor As Long
    15.     lbHatch As Long
    16. End Type
    17. Public Type GRADIENT_RECT
    18.             UpperLeft As Long
    19.             LowerRight As Long  '
    20. End Type
    21.  Type RECT
    22.     Left As Long
    23.     Top As Long
    24.     Right As Long
    25.     Bottom As Long
    26. End Type
    27. Public Type RGB
    28.             R As Integer
    29.             G As Integer
    30.             B As Integer
    31. End Type
    32. Public Const GRADIENT_FILL_RECT_H As Long = &H0
    33. Public Const GRADIENT_FILL_RECT_V  As Long = &H1
    34. Dim ItemRct As RECT
    35. Public Sub LongToRGB(ByVal Color As Long, Optional ByRef red As Long, Optional ByRef green As Long, Optional ByRef blue As Long)
    36.        red = Color And &HFF&
    37.     green = (Color And &HFF00&) / &H100
    38.     blue = (Color And &HFF0000) / &H10000
    39. End Sub
    40. Public Sub DrawBackGrad(ByVal hdc As Long, R As RECT, _
    41.                         Color1 As RGB, _
    42.                         Color2 As RGB, _
    43.                         Direction As Long)
    44. Dim V(1) As TRIVERTEX
    45.     Dim GRct As GRADIENT_RECT
    46.     With V(0)
    47.         .X = R.Left
    48.         .Y = R.Top
    49.         .R = Color1.R
    50.         .G = Color1.G
    51.         .B = Color1.B
    52.         .Alpha = 0
    53.     End With
    54.     With V(1)
    55.         .X = R.Right
    56.         .Y = R.Bottom
    57.         .R = Color2.R
    58.         .G = Color2.G
    59.         .B = Color2.B
    60.         .Alpha = 0
    61.     End With
    62.     GRct.UpperLeft = 0
    63.     GRct.LowerRight = 1
    64. GradientFillRect hdc, V(0), 2, GRct, 1, Direction
    65. End Sub
    66. Sub FadeBackGround(obj As Object, Color1 As Long, Color2 As Long, Vertical As Boolean)
    67. On Error Resume Next
    68. Dim cGrad1 As RGB
    69. Dim cGrad2 As RGB
    70. cGrad1 = GetRGBColors(GetLngColor(Color1))
    71. cGrad2 = GetRGBColors(GetLngColor(Color2))
    72. Call SetRect(ItemRct, 0, 0, obj.Width / Screen.TwipsPerPixelX, obj.Height / Screen.TwipsPerPixelY)
    73. If Vertical = True Then
    74. DrawBackGrad obj.hdc, ItemRct, cGrad1, cGrad2, GRADIENT_FILL_RECT_V
    75. Else
    76. DrawBackGrad obj.hdc, ItemRct, cGrad1, cGrad2, GRADIENT_FILL_RECT_H
    77. End If
    78. End Sub
    79. Public Function GetLngColor(Color As Long) As Long
    80. On Error Resume Next
    81.     If Color And &H80000000 Then
    82.        GetLngColor = GetSysColor(Color And &H7FFFFFFF)
    83.     Else
    84.        GetLngColor = Color
    85.     End If
    86. End Function
    87. Public Function GetRGBColors(Color As Long) As RGB
    88. On Error Resume Next
    89.     Dim HexColor As String
    90.     HexColor = String(6 - Len(Hex(Color)), "0") & Hex(Color)
    91.     GetRGBColors.R = "&H" & Mid(HexColor, 5, 2) & "00"
    92.     GetRGBColors.G = "&H" & Mid(HexColor, 3, 2) & "00"
    93.     GetRGBColors.B = "&H" & Mid(HexColor, 1, 2) & "00"
    94. End Function
    95. Sub Pause(interval)
    96. current = Timer
    97. Do While Timer - current < Val(interval)
    98. DoEvents
    99. Loop
    100. End Sub

    Then to use it do something like...

    Complex Example:
    VB Code:
    1. 'This will randomly fade the control or form with different colors
    2. Private Sub Command1_Click()
    3. On Error Resume Next
    4. Dim R As Long, B As Long, G As Long
    5. Dim reverseR As Boolean, reverseB As Boolean, reverseG As Boolean
    6. R = 0
    7. B = 100
    8. G = 200
    9. Do
    10. DoEvents
    11. Pause (0.01)
    12. If reverseR = False Then R = R + 2
    13. If reverseB = False Then B = B + 3
    14. If reverseG = False Then G = G + 5
    15. If reverseR = True Then R = R - 2
    16. If reverseB = True Then B = B - 3
    17. If reverseG = True Then G = G - 5
    18. If R >= 255 Then reverseR = True
    19. If B >= 255 Then reverseB = True
    20. If G >= 255 Then reverseG = True
    21. If R <= 0 Then reverseR = False
    22. If B <= 0 Then reverseB = False
    23. If G <= 0 Then reverseG = False
    24. Call FadeBackGround(Form1, RGB(R, G, B), RGB(R + 123, G + 234, B + 123), True)
    25. Loop
    26. End Sub


    Simple Example:
    VB Code:
    1. Private Sub Form_Paint()
    2. Call FadeBackGround(Form1, RGB(255, 255, 255), RGB(0, 0, 0), True)
    3. End Sub
    Last edited by Arc; Feb 22nd, 2002 at 01:20 PM.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  33. #73
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    Here's how to write a CGI app in VB. I don't know why anyone would want to do this except to prove it can be done:
    VB Code:
    1. Option Explicit
    2.  
    3. Private Const STD_ERROR_HANDLE As Long = -12&
    4. Private Const STD_INPUT_HANDLE As Long = -10&
    5. Private Const STD_OUTPUT_HANDLE As Long = -11&
    6.  
    7. Private Const GENERIC_WRITE As Long = &H40000000
    8. Private Const FILE_SHARE_READ As Long = &H1&
    9. Private Const OPEN_ALWAYS As Long = 4&
    10. Private Const FILE_ATTRIBUTE_ARCHIVE As Long = &H20&
    11.  
    12. Private Const FILE_END As Long = 2&
    13.  
    14. Private Declare Function CloseHandle Lib "kernel32.dll" (ByVal hObject As Long) As Long
    15.  
    16. Private Declare Function WriteFile Lib "kernel32.dll" (ByVal hFile As Long, _
    17.     lpBuffer As Any, ByVal nNumberOfBytesToWrite As Long, _
    18.     lpNumberOfBytesWritten As Long, lpOverlapped As Any) As Long
    19.    
    20. Private Declare Function CreateFile Lib "kernel32.dll" Alias "CreateFileA" _
    21.     (ByVal lpFileName As String, ByVal dwDesiredAccess As Long, _
    22.     ByVal dwShareMode As Long, lpSecurityAttributes As Any, _
    23.     ByVal dwCreationDisposition As Long, ByVal dwFlagsAndAttributes As Long, _
    24.     ByVal hTemplateFile As Long) As Long
    25.    
    26. Public Declare Function SetFilePointer Lib "kernel32.dll" (ByVal hFile As Long, _
    27.     ByVal lDistanceToMove As Long, lpDistanceToMoveHigh As Long, _
    28.     ByVal dwMoveMethod As Long) As Long
    29.  
    30. Private Declare Function GetStdHandle Lib "kernel32" _
    31.     (ByVal nStdHandle As Long) As Long
    32.    
    33. Private Declare Function GetEnvironmentVariable Lib "kernel32" Alias "GetEnvironmentVariableA" _
    34.     (ByVal lpName As String, ByVal lpBuffer As String, ByVal nSize As Long) As Long
    35.  
    36. Private Declare Function AllocConsole Lib "kernel32" () As Long
    37. Private Declare Function FreeConsole Lib "kernel32" () As Long
    38.  
    39. Public Sub Main()
    40.     Dim STDOUT As Long 'handle to standard output
    41.     Dim strHTTP As String 'data buffer for HTTP header output
    42.     Dim strBuffer As String 'data buffer for writing to the log file
    43.     Dim lngBytesWritten As Long 'the number of bytes that were written
    44.     Dim retval As Long 'API return value
    45.     Dim FILEOUT As Long 'handle to the file to log to
    46.     'CGI Variables
    47.     Dim strQueryString As String
    48.     Dim strRemoteAddr As String
    49.     Dim strHTTPUserAgent As String
    50.    
    51.     'fill the buffers with nothing
    52.     strQueryString = Space$(256)
    53.     strRemoteAddr = strQueryString
    54.     strHTTPUserAgent = strQueryString
    55.    
    56.     'get and store the CGI variables needed
    57.     retval = GetEnvironmentVariable("QUERY_STRING", strQueryString, 256)
    58.     strQueryString = Left$(strQueryString, retval)
    59.     retval = GetEnvironmentVariable("REMOTE_ADDR", strRemoteAddr, 256)
    60.     strRemoteAddr = Left$(strRemoteAddr, retval)
    61.     retval = GetEnvironmentVariable("HTTP_USER_AGENT", strHTTPUserAgent, 256)
    62.     strHTTPUserAgent = Left$(strHTTPUserAgent, retval)
    63.    
    64.     strHTTP = "Location: ./win2000.gif" & vbCrLf & vbCrLf
    65.    
    66.     'start the console
    67.     'retval = AllocConsole 'UNCOMMENT FOR IDE DEBUGGING
    68.    
    69.     'get the handle to standard output
    70.     STDOUT = GetStdHandle(STD_OUTPUT_HANDLE)
    71.    
    72.     'write the string to STDOUT, just like writing to a file
    73.     retval = WriteFile(STDOUT, ByVal strHTTP, Len(strHTTP), lngBytesWritten, ByVal 0&)
    74.  
    75.     'close the handle to standard out
    76.     retval = CloseHandle(STDOUT)
    77.    
    78.     'close the console
    79.     'retval = FreeConsole 'UNCOMMENT FOR IDE DEBUGGING
    80.    
    81.     'open the file for writing
    82.     FILEOUT = CreateFile("C:\Inetpub\wwwroot\Test\image.log", GENERIC_WRITE, FILE_SHARE_READ, _
    83.         ByVal 0&, OPEN_ALWAYS, FILE_ATTRIBUTE_ARCHIVE, 0)
    84.    
    85.     'if error
    86.     If FILEOUT = -1 Then Exit Sub
    87.        
    88.     'fill the buffer
    89.     strBuffer = Now & ";" & strQueryString & ";" & strRemoteAddr & ";" & strHTTPUserAgent & vbCrLf
    90.        
    91.     'move the file pointer to EOF
    92.     retval = SetFilePointer(FILEOUT, 0, 0, FILE_END)
    93.    
    94.     'write the buffer to the file
    95.     retval = WriteFile(FILEOUT, ByVal strBuffer, Len(strBuffer), lngBytesWritten, ByVal 0&)
    96.        
    97.     'close the handle to the file
    98.     retval = CloseHandle(FILEOUT)
    99. End Sub
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  34. #74
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    Heres a function I wrote that is the opposite of IsNumeric. It checks to see if a string is only Alphabetic characters.

    VB Code:
    1. Function IsAlphabetic(sString As String) As Boolean
    2. Dim GetChars As String
    3. Dim i As Integer
    4.    For i = 1 To Len(sString)
    5.       GetChars = Mid(sString, i, 1)
    6.       Select Case Asc(GetChars)
    7.          Case Asc("A") To Asc("Z")
    8.          Case Asc("a") To Asc("z")
    9.          Case Else
    10.             Exit Function
    11.       End Select
    12.    Next i
    13.    IsAlphabetic = True
    14. End Function

    Use it Like

    If IsAlphabetic(text1) then Msgbox "Only Letters are in text1"
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  35. #75
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177
    You can do the same thing, like this:
    VB Code:
    1. Function IsAlpha(ByVal sString As String) As Boolean
    2.     IsAlpha = LCase$(sString$) Like Replace$(Space$(Len(sString$)), " ", "[a-z]")
    3. End Function

  36. #76
    Fanatic Member jian2587's Avatar
    Join Date
    Aug 2000
    Location
    I bet u need a fusion powered shuttle to reach my place...
    Posts
    963
    Well, the gradient fill seems to be complicated, how about this?
    Put a picturebox in a form, set it's Autoredraw property to
    True
    VB Code:
    1. Private Sub Picture1_Click()
    2. Dim FR, FG, FB, LR, LG, LB
    3. Dim SR, SG, SB
    4. 'Any value between 0 and 255 will do for these variables
    5. 'They determine ur first color and last color
    6. FR = 255: FG = 0: FB = 255
    7. LR = 0: LG = 255: LB = 0
    8. With Picture1
    9. SR = (LR - FR) / .Width
    10. SG = (LG - FG) / .Width
    11. SB = (LB - FB) / .Width
    12. For X = 0 To .Width
    13. .Line (X,0) - (X, .Height), RGB(FR, FG, FB)
    14. FR = FR + SR: FG = FG + SG: FB = FB + SB
    15. Next
    16. End With
    17. End Sub
    Now, this would be too slow, How about this?
    This is a few thousand times faster...
    VB Code:
    1. Prinvate Sub Picture1_Click()
    2. Dim FR, FG, FB, LR, LG, LB, PCol, Col, PX
    3. 'Any value between 0 and 255 will do for these variables
    4. 'They determine ur first color and last color
    5. FR = 255: FG = 0: FB = 255
    6. LR = 0: LG = 255: LB = 0
    7. PCol = RGB(FR, FG, FB): PX = 0
    8. With Picture1
    9. SR = (LR - FR) / .Width
    10. SG = (LG - FG) / .Width
    11. SB = (LB - FB) / .Width
    12. Do Until X >= .Width
    13. Col = RGB(FR, FG, FB)
    14. If PCol <> Col Then
    15. .Line (PX, 0) - (X, .Height), PCol, BF
    16. PCol = Col
    17. PX = X
    18. End If
    19. X = X + 1
    20. FR = FR + SR: FG = FG + SG: FB = FB + SB
    21. Loop
    22. End With
    23. End Sub
    ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
    Programming is fun, but only if you're not on a tight deadline
    So I consider all those working engineers sad people

    VB FTP class
    3 page PHP crash course
    Crash Course on DX9 Managed with VB.NET covering basics till terrain creation

  37. #77
    PowerPoster Arc's Avatar
    Join Date
    Sep 2000
    Location
    Under my rock
    Posts
    2,336
    The Gradient fill code I provided is not complicated at all. To use anyway. All you have to do is paste the code into a .bas and then call the Function.

    It is quite a bit longer then your code but then again it looks ALOT smoother. It doesnt have those bars of color... like you can see lines everytime the colors changes a little. My Code gives a very smooth fade with not blockyness or lines.

    Also my code provides both horizontal and vertical fading.


    So it is a bit more code but well worth it imo.
    -We have enough youth. How about a fountain of "Smart"?
    -If you can read this, thank a teacher....and since it's in English, thank a soldier.


  38. #78
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395

    Whats wrong with you Carp???

    did you not get the message last time????

  39. #79
    Member king_willy's Avatar
    Join Date
    Sep 2001
    Location
    Sydney
    Posts
    61

    Talking Subfolders

    Does anyone know how i can add all the file in a folder and all the files in the folders under that one and so on into a list box?

  40. #80
    Megatron
    Guest
    Here's some code that will print the Form. Since it uses PaintPicture, it's more flexible than the PrintForm method.
    VB Code:
    1. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    2.  
    3. 'pic = a hidden picturebox
    4. Private Sub PrintFormEx(pic As PictureBox)
    5.     pic.AutoRedraw = True
    6.     pic.ScaleMode = 3
    7.     pic.Width = Me.ScaleWidth
    8.     pic.Height = Me.ScaleHeight
    9.     BitBlt pic.hDC, 0, 0, Me.Width, Me.Height, Me.hDC, 0, 0, vbSrcCopy
    10.     Picture1.Picture = Picture1.Image
    11.     Printer.PaintPicture pic.Picture, 1440, 1440
    12.     Printer.EndDoc
    13. End Sub
    14.  
    15. 'Usage:
    16.  
    17. PrintFormEx MyPictureBox

Page 2 of 4 FirstFirst 1234 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