• Log in or sign up for an account here: https://www.sythe.org/login

A Few Questions (Focusing, Adding and Decimals)

0h n035

Active Member
Joined
Feb 1, 2007
Sythe Gold
0
Messages
163
Location
Australia
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
 
Two Factor Authentication User
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
 
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 :o
 
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
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 :o

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
 
You just tell your browser that if it redirects to the Windows 404 to instead go to your own

Can you please explain this

^^^ 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 :)
 
^^^ 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 :)

You just add it where and when ever you need focus set the webbrowser.
 
Try on try putting focus on the web browser on the form's GotFocus sub.
 
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).
 
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).

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. ;)
 
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.
 
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.

i think thats because you can only set the borderstyle during design time, nmot run time.
 
Runescape Gamblingrunescape gambling
Back
Top