Hey guys I manged to get some code what works fine but it uses console application

I have tried to convert it by hand and change things around to get it to work but with no avail!

Im certain it should be simple but I may be wrong :(

Code http://pastebin.com/bsbaUThY

Ignore the title of the pastebin its not C# its vb.net

Thanks guys

If you think im trying to be spoon fed I can post my convereted code but it doesnt work and proably 99.9% wrong

I think i would be able to do this if I could call the functions but I get an error doing that because of the variables in the name I think?

any sort of feedback would be nice pulling my hair out over this wont be much left.

Well in a Form project just use labels and textboxes for the console.reads and console.writes
keep the YouTube class and ditch the module Add a Button for the user to click when they have entered the user name and password. Let me know if you need any more help.

That is pretty much What I did and then under a button called main but it didnt work as i think i need to process all functions as I think thats how console works not sure?!

If you put the call to the Youtube class in the Button Click event it should call all the functions/subs. I tried it but as i do not have a YouTube account I couldn't varify that it works only that I failed to log in.

 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim Nick As String = txtUserName.Text
    Dim Pw As String = txtPassword.Text
    Dim B As New Youtube

    lblInfo.Text = ">> Trying to log in ..."
    If B.Login(Nick, Pw) Then
      lblInfo.Text = ">>> Login successfully!"
    Else : lblInfo.Text = ">>> Login failed!"
    End If

  End Sub

YES The label said it logged in but im going to get it to show me the source via richtextbox1

I shall report my findings here thanks!

Okay normally I would know how to add it but I have tried adding it to three different parts with no avail!
http://pastebin.com/tnvPkdYc

Is code im using now feel

Thanks again

I assuming the Return from

Private Function Req(ByVal Site As String, ByVal Met As String, Optional ByVal P As String = "") As String

is the source you are trying to put in a RichTextBox? If so just create a read only property in the YouTube Class and access it after the login and use it for your RichTextBox text. rtbSource is the RichTextBox.

Private m_resp As String

  Public ReadOnly Property Source() As String
    Get
      Return m_resp
    End Get

  End Property



Private Function Req(ByVal Site As String, ByVal Met As String, Optional ByVal P As String = "") As String
    Dim Response As String = String.Empty
    Try
      Dim R As HttpWebRequest = CType(HttpWebRequest.Create(Site), HttpWebRequest)
      R.Method = Met
      R.CookieContainer = Containa
      R.AllowAutoRedirect = True
      R.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0"
      R.ContentType = "application/x-www-form-urlencoded"
      R.ServicePoint.Expect100Continue = False
      If Met = "POST" Then
        R.ContentLength = P.Length
        Dim Wr As New StreamWriter(R.GetRequestStream(), System.Text.Encoding.Default)
        Wr.Write(P)
        Wr.Close()
      End If

      Dim Re As New StreamReader(R.GetResponse.GetResponseStream())
      Response = Re.ReadToEnd
      Re.Close()
    Catch
    End Try
  **  m_resp = Response**
    Return Response
  End Function


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim Nick As String = txtUserName.Text
    Dim Pw As String = txtPassword.Text
    Dim B As New Youtube

    lblInfo.Text = ">> Trying to log in ..."
    If B.Login(Nick, Pw) Then

      lblInfo.Text = ">>> Login successfully!"
    Else
      lblInfo.Text = ">>> Login failed!"

    End If
    rtbSource.Text = B.Source
  End Sub

If this is wrong let me know.

That is perfect actually thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.