1.如何用vb得到网页的源码源代码
2.vb.net如何实现打印DataGridView1里的内容,求源码
3.用VB编个程序,打印计算从1加到100。源码
4.用vb获取任一网页源代码,打印要完整的!!!,可以用webbrowser控件
5.全排列VB源代码
6.求VB源代码!!源码!打印妖差抓妖指标源码
如何用vb得到网页的源码源代码
1 先加载网页:
Private Sub Form_Load()
WebBrowser1.Navigate "/question/.html"
End Sub
2 加载完成后取字符串到文本框:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim doc As Object, objhtml As Object
Dim strhtml As String
On Error GoTo errorsub
Me.Caption = WebBrowser1.LocationName & " 加载完成"
If MaxWebNum <= 0 Then
Set doc = WebBrowser1.Document
Set objhtml = doc.body.createtextrange()
If Not IsNull(objhtml) Then
strhtml = WebBrowser1.Document.body.innertext
Text1.Text = strhtml
End If
End If
Exit Sub
errorsub:
Text1.Text = "错误!!打印!源码"
End Sub
vb.net如何实现打印DataGridView1里的打印内容,求源码
使用 PrintDocument 控件的源码 Print() 方法可以打印指定对象中的内容,参考代码如下:Private Sub Button1_Click(ByVal sender As System.Object,打印 ByVal e As System.EventArgs) Handles Button1.ClickPrintDocument1.Print()
End Sub
Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim bm As New Bitmap(Me.DataGridView1.Width, Me.DataGridView1.Height)
DataGridView1.DrawToBitmap(bm, New Rectangle(0, 0, Me.DataGridView1.Width, Me.DataGridView1.Height))
e.Graphics.DrawImage(bm, 0, 0)
End Sub
用VB编个程序,计算从1加到。源码
以下是打印一个使用 Visual Basic 编写的程序来计算从1加到的求和结果:
下面是程序源码:
Module MainModule
Sub Main()
Dim sum As Integer = 0
For i As Integer = 1 To
sum += i
Next
Console.WriteLine("从1加到的和为:" & sum)
Console.ReadLine()
End Sub
End Module
这个程序使用了一个 `For` 循环来进行累加求和,初始值为 1,源码终止值为 。
在循环中,通过 `sum += i` 来将每个数字累加到 `sum` 变量上。
最后,淘源码php源码打印出求和结果。
你可以将这段代码粘贴到 Visual Studio 或其他 VB 开发环境中进行编译和运行。
运行程序后,你将在控制台中看到输出结果:"从1加到的和为:"。
用vb获取任一网页源代码,要完整的!!!,可以用webbrowser控件
'你把下面的代码保存为Form1.frm,然后双击打开该文件,运行后按提示即可看到结果。
'呵呵,够详细了,源码通棋牌源码再不会我也没办法了。
'====文件Form1.frm====
VERSION 5.
Begin VB.Form Form1
Caption = "Form1"
ClientHeight =
ClientLeft =
ClientTop =
ClientWidth =
LinkTopic = "Form1"
ScaleHeight =
ScaleWidth =
StartUpPosition = 3 '窗口缺省
Begin VB.TextBox Text2
Height =
Left =
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 2
Top =
Width =
End
Begin VB.TextBox Text1
Height =
Left =
TabIndex = 1
Text = "我的家"
Top =
Width =
End
Begin VB.CommandButton Command1
Caption = "获取HTML源码"
Height =
Left =
TabIndex = 0
Top =
Width =
End
Begin VB.Label Label2
Caption = "注意:获取源码之前必须先用IE打开网址,然后输入窗口标题关键字。如www..com的标题关键字是:我的家"
Height =
Left =
TabIndex = 4
Top =
Width =
End
Begin VB.Label Label1
Caption = "请输入IE窗口标题:"
Height =
Left =
TabIndex = 3
Top =
Width =
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Function GetIeHtml(IeTitle As String) As String
Dim oShellApp: Set oShellApp = CreateObject("Shell.Application")
Dim oShellAppWindows: Set oShellAppWindows = oShellApp.Windows
Dim owin
'获取弹出的IE窗口
For Each owin In oShellAppWindows '获取弹出的IE窗口
If LCase(TypeName(owin.Document)) = "htmldocument" And _
InStr(1, owin.LocationName, IeTitle, vbTextCompare) > 0 Then '如果找到符合条件的IE窗口
GetIeHtml = owin.Document.activeElement.Document.documentElement.innerHTML '此句可获得完整html代码
GoTo Mend '退出
End If
Next
Mend:
Set oShellAppWindows = Nothing
Set oShellApp = Nothing
Set owin = Nothing
End Function
Private Sub Command1_Click()
Dim S As String
S = GetIeHtml(Text1.Text) '表示获得标题含有"我的家"的html代码
Text2.Text = S
End Sub
Private Sub Form_Load()
'Shell "explorer.exe ""/""", vbNormalNoFocus
End Sub
全排列VB源代码
文章标题:全排列VB源代码与C++实现,附非递归算法解答在编程世界中,全排列算法是一个常被提及的主题,尤其在解决组合数学问题时。本文将展示如何使用 Visual Basic (VB) 和 C++ 语言实现全排列,并提供一个非递归算法的源码下载免费源码解答,帮助读者理解和解决相关问题。
首先,让我们聚焦于 VB 语言的实现。在 VB 中,我们可以通过编写一段代码来生成给定字符串的所有全排列。下面是一个典型的 VB 代码示例:
vb
Option Explicit
Private Sub Command1_Click()
Dim nt As Double: nt = Timer
List1.Visible = False: List1.Clear
Permutation("", Text1.Text)
List1.Visible = True
Debug.Print Timer - nt,
End Sub
Private Sub Permutation(pre As String, s As String)
Dim i As Long
If Len(s) = 1 Then List1.AddItem pre & s: Exit Sub
For i = 1 To Len(s)
Permutation(pre & Mid$(s, i, 1), Left$(s, i - 1) & Mid$(s, i + 1))
Next
End Sub
这段代码实现了一个递归过程来生成全排列。它首先检查字符串的长度,如果长度为1,则直接将字符串与前面的源码商城平台源码元素合并并添加到列表中。如果字符串长度大于1,则进行循环以取出待排列串的任意一位,并将该字符插入到已取出的字符串后,然后递归调用自身,同时更新待排列的字符串。这一过程一直持续到所有字符排列完成。
接下来,我们转向 C++ 实现,一种更广泛使用的编程语言。C++ 中的全排列实现通常使用模板类,以适应不同类型的元素。下面是一个简单的 C++ 全排列实现:
cpp
template class Type>
void Perm(Type list[], int k, int m) {
if (k == m) {
for (int i = 0; i <= m; i++) {
cout << list[i];
}
cout << endl;
} else {
for (int i = k; i <= m; i++) {
Swap(list[k], list[i]);
Perm(list, k + 1, m);
Swap(list[k], list[i]);
}
}
}
此模板函数 `Perm` 接受一个类型为 `Type` 的数组、起始索引 `k` 和结束索引 `m`,并递归地生成从 `k` 到 `m` 的数组的所有全排列。通过交换数组中的元素,我们逐步构建全排列并打印结果。
对于一个非递归的全排列算法,我们可以通过一个循环和条件判断来实现。下面是一个用 C++ 实现的非递归算法:
cpp
#include
int *n;
void arge(int *x, int size) {
int *t = new int[size];
int totoal = 0;
int pos = size - 2;
int just = 0;
for (int i = 0; i < size; i++) {
t[0] = 1;
}
while (1) {
for (int i = 0; i < size; i++) {
printf("%d ", x[i]);
}
printf("\n");
totoal++;
pos = size - 2;
while (x[pos] > x[pos + 1]) {
pos--;
t[x[pos + 1] - 1] = 0;
}
if (pos < 0) {
break;
}
t[x[pos] - 1] = 0;
t[x[pos + 1] - 1] = 0;
for (int i = pos + 1; i < size; i++) {
for (int j = 1; j <= size; j++) {
if (t[j - 1] == 0) {
x[i] = j;
t[j - 1] = 1;
break;
}
}
}
}
printf("totoal = %d\n", totoal);
delete[] t;
}
这个非递归算法通过使用一个辅助数组 `t` 来跟踪已排序的元素,从而避免了递归调用。通过循环和条件判断,该算法实现了从数组中生成全排列,并打印每个排列的结果。
通过以上三种不同的实现方式,我们可以看到全排列问题在不同编程语言中的解法,每种方法都有其优势和应用场景。理解这些不同的解决方案有助于提升编程技能,解决更多复杂问题。
扩展资料
从n个不同元素中任取m(m≤n)个元素,按照一定的顺序排列起来,叫做从n个不同元素中取出m个元素的一个排列。当m=n时所有的排列情况叫全排列。
求VB源代码!!!
用记事本把下面的代码保存到Form1.Frm文件中。然后用VB打开,试试吧。
===========
VERSION
5.
Begin
VB.Form
Form1
BorderStyle
=
1
'Fixed
Single
Caption
=
"打地鼠"
ClientHeight
=
ClientLeft
=
ClientTop
=
ClientWidth
=
LinkTopic
=
"Form1"
MaxButton
=
0
'False
MinButton
=
0
'False
ScaleHeight
=
ScaleWidth
=
StartUpPosition
=
3
'窗口缺省
Begin
VB.CommandButton
Command1
Caption
=
"开始"
Height
=
Left
=
0
TabIndex
=
9
Top
=
Width
=
End
Begin
VB.Timer
Timer1
Interval
=
Left
=
Top
=
End
Begin
VB.PictureBox
Picture1
Height
=
Index
=
8
Left
=
ScaleHeight
=
ScaleWidth
=
TabIndex
=
8
Top
=
Width
=
End
Begin
VB.PictureBox
Picture1
Height
=
Index
=
7
Left
=
ScaleHeight
=
ScaleWidth
=
TabIndex
=
7
Top
=
Width
=
End
Begin
VB.PictureBox
Picture1
Height
=
Index
=
6
Left
=
0
ScaleHeight
=
ScaleWidth
=
TabIndex
=
6
Top
=
Width
=
End
Begin
VB.PictureBox
Picture1
Height
=
Index
=
5
Left
=
ScaleHeight
=
ScaleWidth
=
TabIndex
=
5
Top
=
Width
=
End
Begin
VB.PictureBox
Picture1
Height
=
Index
=
4
Left
=
ScaleHeight
=
ScaleWidth
=
TabIndex
=
4
Top
=
Width
=
End
Begin
VB.PictureBox
Picture1
Height
=
Index
=
3
Left
=
0
ScaleHeight
=
ScaleWidth
=
TabIndex
=
3
Top
=
Width
=
End
Begin
VB.PictureBox
Picture1
Height
=
Index
=
2
Left
=
ScaleHeight
=
ScaleWidth
=
TabIndex
=
2
Top
=
0
Width
=
End
Begin
VB.PictureBox
Picture1
Height
=
Index
=
1
Left
=
ScaleHeight
=
ScaleWidth
=
TabIndex
=
1
Top
=
0
Width
=
End
Begin
VB.PictureBox
Picture1
Height
=
Index
=
0
Left
=
0
ScaleHeight
=
ScaleWidth
=
TabIndex
=
0
Top
=
0
Width
=
End
Begin
VB.Label
Label1
AutoSize
=
-1
'True
Height
=
Left
=
TabIndex
=
Top
=
Width
=
End
End
Attribute
VB_Name
=
"Form1"
Attribute
VB_GlobalNameSpace
=
False
Attribute
VB_Creatable
=
False
Attribute
VB_PredeclaredId
=
True
Attribute
VB_Exposed
=
False
Dim
i
As
Integer,
t
As
Integer
Private
Sub
Command1_Click()
On
Error
GoTo
hErr
t
=
2
*
InputBox("请设置游戏时间,单位为秒:",
,
)
Caption
=
0
Timer1.Enabled
=
True
Command1.Enabled
=
False
hErr:
End
Sub
Private
Sub
Form_Load()
Timer1.Enabled
=
False
Randomize
For
Each
p
In
Picture1
p.FontName
=
"arial"
p.FontSize
=
Next
End
Sub
Private
Sub
Picture1_Click(Index
As
Integer)
If
Index
=
i
Then
Caption
=
Caption
+
1:
t
=
t
+
1:
Timer1_Timer
End
Sub
Private
Sub
Timer1_Timer()
For
Each
p
In
Picture1
p.Cls
Next
i
=
Int(Rnd
*
9)
Picture1(i).Print
i
+
1
t
=
t
-
1
Label1.Caption
=
"倒计时:"
&
Int(t
/
2)
If
t
=
0
Then
Timer1.Enabled
=
False:
MsgBox
"游戏结束,您共打到"
&
Caption
&
"次地鼠":
i
=
-1:
Command1.Enabled
=
True
End
Sub