A Few Questions (Focusing, Adding and Decimals)

Discussion in 'Programming General' started by 0h n035, Apr 4, 2008.

A Few Questions (Focusing, Adding and Decimals)
  1. Unread #1 - Apr 4, 2008 at 7:20 PM
  2. 0h n035
    Joined:
    Feb 1, 2007
    Posts:
    163
    Referrals:
    0
    Sythe Gold:
    0

    0h n035 Active Member

    A Few Questions (Focusing, Adding and Decimals)

    Hello. I've been getting into a couple VB Projects but now I have some questions.

    Firstly, when I go to A Firefox window and back to my client, I have to DOUBLE CLICK my Webbrowser before i can type in it. How can I make it so it automatically focuses to the Webbrowser when i open up the Client OR make it so I only need to click once. The Webbrowser is in a frame if that helps.

    Secondly, I've been making a program that grabs share info from other sites for my dad. I have:

    Code:
    Shares.UnitShares.Caption = Prefix & AUW4(0) + AVE4(0) + BHP4(0) + CBA4(0) + GFF4(0) + KBC4(0) + MXI4(0) + NAB4(0) + OKN4(0) + QAN4(0) + RIO4(0) + SKE4(0) + SUN4(0) + WBC4(0) + WHG4(0)
    The AUW4(0), etc are the numbers grabbed from other sites. But this doesn't add them. Instead, it puts all the numbers together. EX: Instead of Adding 1.75 and 2.35, it puts them together like: 1.752.35. What have I done wrong?

    LASTLY, when grabbing these numbers, how do I make it round it to two Decimal Places? I DON'T want it to just cut the numbers off. I want it to actually ROUND it.

    Thanks,
    0h N035
     
  3. Unread #2 - Apr 4, 2008 at 9:22 PM
  4. Flaming Idiots
    Joined:
    Dec 22, 2005
    Posts:
    235
    Referrals:
    1
    Sythe Gold:
    0
    Two Factor Authentication User

    Flaming Idiots Active Member
    Visual Basic Programmers

    A Few Questions (Focusing, Adding and Decimals)

    For your problem adding the values, it is probably because they are strings, not numbers. So, try using this function to add them.

    Code:
    Public Function Sum(ParamArray I() As Variant) As Double
        Sum = 0
        On Error Resume Next
        For Each Var In I
            Sum = Sum + CDbl(Var)
        Next Var
    End Function
    You can use it like this for your code:
    Code:
    Dim X As String
    X = Prefix & Sum(AUW4(0), AVE4(0), BHP4(0), CBA4(0), GFF4(0), KBC4(0), MXI4(0), NAB4(0), OKN4(0), QAN4(0), RIO4(0), SKE4(0), SUN4(0), WBC4(0), WHG4(0))
    For rounding numers, there is a built in Round function which you use like this:
    Code:
        Dim Pi As Double, ShortPi As Double
        Pi = 3.14159265
        ShortPi = Round(Pi, 2) ' ShortPi should be: 3.14
    Just make sure you are using Doubles instead of Integers, since Integers do not support decimals
     
  5. Unread #3 - Apr 8, 2008 at 5:44 PM
  6. 0h n035
    Joined:
    Feb 1, 2007
    Posts:
    163
    Referrals:
    0
    Sythe Gold:
    0

    0h n035 Active Member

    A Few Questions (Focusing, Adding and Decimals)

    Thanks, they worked :)

    I don't know if i'm lucky though, cos the Decimals worked with Integers.

    EDIT: 1 more question. How do I make 404 Error pages for my Web Browser :eek:
     
  7. Unread #4 - Apr 9, 2008 at 8:38 AM
  8. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    A Few Questions (Focusing, Adding and Decimals)

    You just tell your browser that if it redirects to the Windows 404 to instead go to your own. Oh, and for the focus on the browser thing, it's:

    WebBrowser1.SetFocus
     
  9. Unread #5 - Apr 9, 2008 at 8:53 AM
  10. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    A Few Questions (Focusing, Adding and Decimals)

    Can you please explain this, i've been yelling at my computer for the past hour and a half and it either doesn't understand english or its ignoring me.

    Please help.
     
  11. Unread #6 - Apr 11, 2008 at 6:14 PM
  12. 0h n035
    Joined:
    Feb 1, 2007
    Posts:
    163
    Referrals:
    0
    Sythe Gold:
    0

    0h n035 Active Member

    A Few Questions (Focusing, Adding and Decimals)

    ^^^ I'm sort of a beginner :p

    And with Setfocus, where do I put it. I'm guessing there's be something like

    Private Sub (Something to do with windowstate here?)
    WebBrowser1.SetFocus
    End Sub

    I'll look into it but I probably won't be able to find an answer, because I made a search not to long ago and found Nilch.

    Thanks Anyway :)
     
  13. Unread #7 - Apr 12, 2008 at 2:33 AM
  14. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    A Few Questions (Focusing, Adding and Decimals)

    You just add it where and when ever you need focus set the webbrowser.
     
  15. Unread #8 - Apr 17, 2008 at 4:56 AM
  16. 0h n035
    Joined:
    Feb 1, 2007
    Posts:
    163
    Referrals:
    0
    Sythe Gold:
    0

    0h n035 Active Member

    A Few Questions (Focusing, Adding and Decimals)

    I need it to focus when the window is Restored.
     
  17. Unread #9 - Apr 17, 2008 at 7:12 AM
  18. jdsfighter
    Joined:
    Jan 21, 2007
    Posts:
    603
    Referrals:
    0
    Sythe Gold:
    0

    jdsfighter Forum Addict
    Visual Basic Programmers

    A Few Questions (Focusing, Adding and Decimals)

    Try on try putting focus on the web browser on the form's GotFocus sub.
     
  19. Unread #10 - Apr 17, 2008 at 9:01 PM
  20. 0h n035
    Joined:
    Feb 1, 2007
    Posts:
    163
    Referrals:
    0
    Sythe Gold:
    0

    0h n035 Active Member

    A Few Questions (Focusing, Adding and Decimals)

    Alright, I'll give it a go ;)

    EDIT: That probably worked. But i think the real problem is that i need it t focus on what's INSIDE the browser. For example, if RuneScape is open, it needs to focus on that, not the page it's on.'

    EDIT2: Need more help. I've put a button on my form which isn't doing what I want. I was hoping that I could get it to make my form full screen but i won't. I have:

    Me.BorderStyle = 0 (0 Is None)

    And it does nothing. I want it so when the button is clicked it goes into fullscreen (Like Games).
     
  21. Unread #11 - Apr 18, 2008 at 12:58 AM
  22. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    A Few Questions (Focusing, Adding and Decimals)

    For your first problem, look at these API's.
    GetForeGroundWindow
    SetForeGroundWindow
    SendMessage

    Those are the 3 API's that can solve your problem.
    As for your fullscreen button problem...i thought the whole "borderstyle" gave it away...

    What you are doing is changing the borderstyle of your form, not the actual size of your form. You need to use "WindowState".
    Code:
    Me.WindowState = 2
    Not 100% sure its 2, you will have to check and make sure. I think 0 is minimize and 1 is normal.

    Also i'd easily make this for you, but since your using this for malicious uses you gotta work for it. ;)
     
  23. Unread #12 - Apr 18, 2008 at 5:19 AM
  24. 0h n035
    Joined:
    Feb 1, 2007
    Posts:
    163
    Referrals:
    0
    Sythe Gold:
    0

    0h n035 Active Member

    A Few Questions (Focusing, Adding and Decimals)

    Thanks I'll try out he first one tomorrow, but I don' want to maximize my window. I actually want it FULL Screen. Like when you press F11.

    Th BorderStyle thing removes the border which i used to make a fullscreen program before. I tried making it change on this but it wouldn't.
     
  25. Unread #13 - Apr 18, 2008 at 10:06 AM
  26. Covey
    Joined:
    Sep 9, 2005
    Posts:
    4,510
    Referrals:
    9
    Sythe Gold:
    9
    Discord Unique ID:
    807246764155338833
    Discord Username:
    Covey#1816

    Covey Creator of EliteSwitch
    Retired Sectional Moderator Visual Basic Programmers

    A Few Questions (Focusing, Adding and Decimals)

    i think thats because you can only set the borderstyle during design time, nmot run time.
     
  27. Unread #14 - Apr 18, 2008 at 6:51 PM
  28. 0h n035
    Joined:
    Feb 1, 2007
    Posts:
    163
    Referrals:
    0
    Sythe Gold:
    0

    0h n035 Active Member

    A Few Questions (Focusing, Adding and Decimals)

    Hmm... Any other ideas?
     
< Coding | file parser.... thing >

Users viewing this thread
1 guest


 
 
Adblock breaks this site