如何从pastebin中获取文本时修复此错误?

时间:2015-02-15 21:24:39

标签: vb.net

我最近一直试图通过inputbox获取原始文本,它似乎工作了一点,但返回的文本不是来自给定网址的文本,它说"请刷新页面继续... "在richtextbox上,我该如何解决这个问题?我猜我说错了,但我不知道这就是问题。

Imports System.Net

Public Class Form1
    Dim web As New WebClient
    Dim PastebinLink As String
    Dim Newcode As String = web.DownloadString("http://pastebin.com/raw.php?i=") + PastebinLink

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub FontToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles FontToolStripMenuItem.Click
        FD.ShowDialog()
        CodeBox.Font = FD.Font
    End Sub

    Private Sub SaveToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles SaveToolStripMenuItem.Click
        Save.ShowDialog()
        If Save.ShowDialog = Windows.Forms.DialogResult.OK _
        Then
            My.Computer.FileSystem.WriteAllText _
            (Save.FileName, CodeBox.Text, True)
        End If
    End Sub

    Private Sub GetPastebinToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles GetPastebinToolStripMenuItem.Click
        MsgBox("This will erase all current work! we suggest saving!", MsgBoxStyle.OkOnly, "Warning")
        PastebinLink = InputBox("Enter the sublink of pastebin URL EG: aXL1i5S")
        CodeBox.Text = Newcode
    End Sub
End Class

1 个答案:

答案 0 :(得分:2)

您的设置仅限新密码

Dim PastebinLink As String
Dim Newcode As String = web.DownloadString("http://pastebin.com/raw.php?i=") + PastebinLink
  1. PastebinLink是String.Empty或""
  2. 您正尝试从 http://pastebin.com/raw.php?i= 下载一个字符串,并在下载的字符串中附加 PastebinLink <中的空字符串/强>
  3. 在您的子 GetPastebinToolStripMenuItem_Click 中,您将 CodeBox.Text 设置为 Newcode 但是你永远不会更新它,你总会得到相同的内容。

    至少在您的点击处理程序中,您应该使用新链接下载。

    CodeBox.Text = web.DownloadString("http://pastebin.com/raw.php?i=" & PastebinLink)