我仍然试图从网页中获取一些数据,我得到了一个解决方法,如何"grep"HTML文本,但现在我试图将一些部分与此文本中的字符串分开.
我想取出变量A和变量B之间的一部分,并使用以下代码.
我总是得到一个Runtime error 6 Overflow,有人知道我为什么以及如何解决这个问题?
Sub Button1_Click()
Const HTTPREQUEST_PROXYSETTING_PROXY = 2
Dim oRequest As Object, pagetext, third As String, first, second As Integer
Set oRequest = CreateObject("WinHttp.WinHttpRequest.5.1")
oRequest.Open "GET", "http://www.vodafone.de/privat/handys-tablets-tarife/smartphone-tarife.html"
oRequest.Send
pagetext = oRequest.ResponseText
first = InStr(pagetext, "window.phones")
second = InStr(first + 1, pagetext, "window.propositions")
third = Mid(pagetext, first + 1, second - first - 1)
MsgBox (third)
End Sub
Run Code Online (Sandbox Code Playgroud) 我试图打开一个文件,但它无法正常工作.
Workbook.Open C:\users\me\desktop\testfile.txt
Run Code Online (Sandbox Code Playgroud)
我总是收到错误消息:运行时错误'424':需要对象
我只是想打开一个文件.如果文件是exel,txt,jpg或word文件,则不修复.
应该尽可能简单.
我正在尝试将数据库中的信息保存到字符串中.
如何通过以下代码实现这一目标?
using (SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString))
{
SqlCommand cmd = new SqlCommand("SELECT something FROM table");
cmd.CommandType = CommandType.Text;
cmd.Connection = connection;
connection.Open();
cmd.ExecuteNonQuery();
connection.Close();
}
Run Code Online (Sandbox Code Playgroud)
是否可以使用它从数据库中获取一些值string?