函数start不会在所有代码路径上返回值。使用结果时,可能会在运行时发生空引用异常

问题描述 投票:-1回答:1

你可以帮助它说(函数'开始'不会在所有代码路径上返回一个值。使用结果时,运行时可能会出现空引用异常。)

Private Function Start() As Object
    Dim thr As Integer = TextBox4.Text
    Dim Threading As Integer = Nothing
    If CheckBox1.Checked = True Then
        Threading = thr + 300
    Else
        Threading = thr
    End If
    While Not stopp
        Try
            Try
                Dim i As String = Geting("https://i.instagram.com/api/v1/users/search?q=" & TextBox5.Text & "&access_token=" & Guid.NewGuid.ToString.ToUpper & "/")
                If i.Contains("""username"": """ & TextBox5.Text & """") Or Nothing Then
                    intt += 1
                    Me.Invoke(Sub() TextBox3.Text = intt)
                Else
                    If ChangeUserName(TextBox5.Text) Then
                        Me.Invoke(Sub() Label1.Text = "username claimed " & TextBox5.Text)
                        stopp = True
                    End If
                End If
            Catch ex2 As Exception
            End Try
            Thread.Sleep(Threading)
        Catch ex As Exception
        End Try
    End While
End Function
vb.net
1个回答
-1
投票

您可能不需要从函数返回值。更改

Private Function Start() As Object

Private Sub Start()

作为旁注,您的错误处理很糟糕。

Try
    (Do something)
Catch Exception
End Try

永远不应该使用。它可以防止您在出现问题时查看(即使您的代码存在缺陷)。

© www.soinside.com 2019 - 2024. All rights reserved.