• Welcome to Valhalla Legends Archive.
 

[VB6] Help?

Started by Pedlar, April 21, 2005, 07:05 PM

Previous topic - Next topic

Pedlar

I got another quick question.  How would i go abou retrieveing a string from a URL and puting it through AddChat?  I was thinking do Open("http://url/news.txt") and parsing it that way. But it didnt quite work :(

Yegg

I don't use VB6 all that often (I use Python), but doesn't VB6 have a way to read the text stored in a text document from the internet? I think you might be able to use Inet for this task. I can't really go into detail on that for you though.

Hdx

Yes, Simply using an Inet control will allow you to access any publically web-based text doccument.
Dim FileData as string
FileData = Inet1.OpenURL("Http://URL/File.txt")

~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Archangel

Quote from: HdxBmx27 on April 23, 2005, 05:39 PM
Yes, Simply using an Inet control will allow you to access any publically web-based text doccument.
Dim FileData as string
FileData = Inet1.OpenURL("Http://URL/File.txt")

~-~(HDX)~-~

You can also split the data by character 10 (Chr(10)),
and then add it to chat.
I'm not an Addict.

Pedlar


Pedlar

Ok, I found the dll with Inet :D, But now i have a not so easy question, How would i  do the Url so in the txt file i can have AddChat "Blah" and when i load the file have it do whats in the file? so i could do say Inet1.openURL("http://LovelyUrl/News.txt") then it call the functions inside the file?

Edit: I can elaborate abit more if this question confuses someone.

Hdx

#21
Umm, Elaborate please You need to simply put the results of OpenURL() into a vareable, Like ArchAngel you can split it by Chr(&HA) witch would return all the line breaks.

Are you refering to VB code in the file, if so then youll have to look into the Scripting object control. If your jsut making a file where you can have news, simply so the AddChat with the data you get, Even make some special charecters for yourself to tell you how it should be displayed (bold, italic, underline, red, blue, clear, etc....)
~-~(HDX)~-~

Proud host of the JBLS server www.JBLS.org.
JBLS.org Status:
JBLS/BNLS Server Status

Pedlar

yea what im asking is basicly a Remote VBScript

Pedlar

#23
Edit: I ask for help to be pushed in the right direction, Ive never realy used VB before. Im more C, So dont think im jus building my bot off of what you all are telling me.

With help from HDX i was able to get what i needed, but now when i do ScriptSupportClass.AddChat vbCyan, "Hi" it shows it in black instead of Cyan, this is what i have for AddChat inside of the script suport class
Edit: Changed the AddChat

Public Sub AddChat(ParamArray saElements() As Variant)
    Dim i As Integer
    For i = LBound(saElements) To UBound(saElements) Step 2
        With frmChat.rtbChat
        .SelStart = Len(.text)
        .SelLength = 0
        .SelColor = saElements(i)
        .SelText = saElements(i + 1) & Left$(vbCrLf, -2 * CLng((i + 1) = UBound(saElements)))
        .SelStart = Len(.text)
        End With
    Next i
End Sub

and in form_load i have

    Dim NewsData As String
    Set ScriptSupportClass = New ScriptSupportClass
    NewsData = Inet1.OpenURL("Http://Url/canews.txt")
    caScript.AddCode (NewsData)
    caScript.Run ("News")

and last but not least in canews.txt i have

Public Sub News()
ScriptSupportClass.AddChat vbWhite, "[" & Time & "] ", vbcyan , "Hi"
End Sub

QwertyMonster

#24
Perhaps this could help you? Look at it and compare and see what your doing wrong.


Public Function Display(ByVal TextObject As RichTextBox, ByVal NewLine As Boolean, ByVal TimeStamp As Boolean, ByVal TextColor As Long, ByVal Text As String)

    TextObject.SelStart = Len(TextObject.Text)
       
    If NewLine = True And TextObject.Text <> "" Then TextObject.SelText = TextObject.SelText & vbCrLf
       
    If TimeStamp = True Then
       
        TextObject.SelColor = &H8000000F
        TextObject.SelText = TextObject.SelText & "[" & Time & "] "
           
    End If
       
    TextObject.SelColor = TextColor
    TextObject.SelText = TextObject.SelText & Text
    TextObject.SelStart = Len(TextObject.Text)
   
End Function


Edit: Forgot to say how its used. Its used like this.


Display MyRTB, true, true, vbGreen, "Wee"

1st true = NewLine.
2nd true = Timestamp.

Put both to false if want  to stay on same line, with no timestamp but change colour writing.

Hope this helps!

Pedlar

When i pass stuff through the script support class it removes there color...i can do AddChat Blah, and have color and do ScriptSupportClass..AddChat blah and it jus turned it black.

R.a.B.B.i.T

You really should use a socket, not INet, because INet sucks and often errors itself to death.

Archangel

TIPS:

- Connect socket!
- On Connect:

Winsock1.SendData "GET http://yoursite/news.txt HTTP/1.0" & vbCrLf & _
                  "Connection: Keep-Alive" & vbCrLf & _
                  "Accept: */*" & vbCrLf & _
                  "Accept-Language: en" & vbCrLf & vbCrLf

- Data Arrives, and you parse data.
I'm not an Addict.

Pedlar

im not having a problem retriveing the info or even having the script work, the only thing thats wrong is that the AddChat in the ScriptSupportClass wont call color, but its identicle to the AddChat in frmChat whcih does show color. So any help with why puting something through the scriptsupportclass wonr show color is well apreciated.

[Edit]: Spelling.

R.a.B.B.i.T

Quote from: Archangel on April 24, 2005, 04:02 PM
TIPS:

- Connect socket!
- On Connect:

Winsock1.SendData "GET http://yoursite/news.txt HTTP/1.0" & vbCrLf & _
                  "Connection: Keep-Alive" & vbCrLf & _
                  "Accept: */*" & vbCrLf & _
                  "Accept-Language: en" & vbCrLf & vbCrLf

- Data Arrives, and you parse data.
That won't work :'(

        Sock.SendData "GET /news.txt HTTP/1.1" & vbCrLf & _
                  "Host: www.site.com" & vbCrLf & _
                  "Accept: */*" & vbCrLf & _
                  "Accept-language: en" & vbrclf & vbCrLf

|