Question[Help]# Posts in a forum[solved]

Posts 31–45 of 46 · Page 3 of 4
Hold on, I am writing you a check if user is logged in code, with error handling and the click event.
Quote Originally Posted by NextGen1 View Post
Hold on, I am writing you a check if user is logged in code, with error handling and the click event.
[php]If webbrowser1.documenttext.contains("Search") then
Msgbox("User is logged in")
else
Msgbox("User is not logged in")
end if[/php]


...
End if

Noob =P
Quote Originally Posted by Blubb1337 View Post
...
End if

Noob =P
I wrote it in mpghs textbox, so thats why I forgot end if
Mine is more elaborate to allow flag checks for use with other features.

On top of that, you got that from me in a prior thread a few months ago anyway, so I

Check User Login Status
[php]
Dim Loggedin As Boolean
Try
If WebBrowser1.Document.GetElementById("navbar_search ").InnerText = "Search" Then
Loggedin = True
Else
Loggedin = False
End If
Catch ex As Exception
' If the user is not logged in then ask the user to login and send them to the login page
MsgBox("please login")
WebBrowser1.Navigate("www.mpgh.net/login")
End Try
[/php]

Then you can use the Flag If loggedin=true then for everything
(just be sure the loggedin is set = true after user logs in)

Instead of writing a Href walk through I am going to use invoke member on the link location,

The code to click the link of your name is

Click Your Name
[php]
WebBrowser1.Document.Links(30).InvokeMember("Click ")
[/php]
(note: this is always true, unless the website changes, in which case, looping through Hrefs will work better, but then you will need to know the users login name so you know which href to search for (anchors, attributes) , which will only complicate the application)

Click Your Mood (cause you can)
[php]
WebBrowser1.Document.Links(31).InvokeMember("Click ")
[/php]

So essentially, now you have a way to check without using try and exception handlers a way to determine if the user is logged in, then click it

so

[php]
If loggedin=true then
WebBrowser1.Document.Links(30).InvokeMember("Click ")
else
MsgBox("please login")
WebBrowser1.Navigate("www.mpgh.net/login")
end if
[/php]

I would also be sure to create settings for everything you want the user to be able to store.

IE: Url of profile for use for posts. Should be saved as a setting, so the user only need access the page once during the initial setup
ty so much it worked.

also

Lets says I have this line:
686 (5.66 per day)

How do i remove the everything in between and including "(" and ")"

So final line would be:
686
Where are you getting that from?

It would be string manipulation to remove it, but if you are using statistics in the profile page, it's a separate list item in the unsorted list tags
nvm got it.

for this code:
Code:
        While Not WebBrowser1.ReadyState = WebBrowserReadyState.Complete
            Application.DoEvents()
        End While
do you put the codes underneath "Application do events" or do u remove it then add ur codes?
dim s as string
s=posts.replace("5.66 per day","")
do you know how to mute the click sound when something is clicked on a webbrowser?
Create a sub , Call it Public Sub MuteSound()

[php]
Dim key As String
key = "%SystemRoot%\Media\"
' Checks windows OS Versions to determine which path to use
If Environment.OSVersion.Version.Major = 5 AndAlso Environment.OSVersion.Version.Minor > 0 Then
key += "Windows XP Start.wav"
ElseIf Environment.OSVersion.Version.Major = 6 Then
key += "Windows Navigation Start.wav"
Else
Return
End If
' Sets Explorer click Sounds off with a registry modification.
Dim key2 As RegistryKey = Registry.CurrentUser.OpenSubKey("AppEvents\Schemes \Apps\Explorer\Navigating\.Current", True)
key2.SetValue(Nothing, "", RegistryValueKind.ExpandString)
[/php]

In form load add
[php]
MuteSound()
[/php]

once it is off though, it is off, so you will need to modify it to turn it back on , so on application end call

[php]
playsound()
[/php]

Code for that is

Create a sub , Call it Public Sub PlaySound()

[php]
Dim key3 As String
key3 = "%SystemRoot%\Media\"
If Environment.OSVersion.Version.Major = 5 AndAlso Environment.OSVersion.Version.Minor > 0 Then
key3 += "Windows XP Start.wav"
ElseIf Environment.OSVersion.Version.Major = 6 Then
key3 += "Windows Navigation Start.wav"
Else
Return
End If
Dim key4 As RegistryKey = Registry.CurrentUser.OpenSubKey("AppEvents\Schemes \Apps\Explorer\Navigating\.Current", True)
key4.SetValue(Nothing, key3, RegistryValueKind.ExpandString)

[/php]

This should do it

Really MSDN standard

do you have to import something?

cause RegistryKey is not defined for both.


[php]
Imports Microsoft.Win32
[/php]


One more issue, forgot to set the value
It is

Code:
     Dim key2 As RegistryKey = Registry.CurrentUser.OpenSubKey("AppEvents\Schemes\Apps\Explorer\Navigating\.Current", True)
        key2.SetValue(Nothing, "", RegistryValueKind.ExpandString)
Corrected it in the other post, sorry about that.
ok tyvm.

btw how do you prevent backspace from "going back one page" in a webbrowser?
Yes,

I don't remember the code, just look up how to return a keycode as false, I have never had to use it, I remember learning it during VB boot camp, but I don't remember the actual code, If I get a chance Ill look or try to remember.

Essentially the code checks for the keycode = 8 and will normally return it true, you want it to return false
Posts 31–45 of 46 · Page 3 of 4
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us