1、 尝试安装virtual studio2010
由于下载的一个项目用2017打开出错,于是下载2010,http://www.pcsoft.com.cn/soft/121336.html下载。
双击 iso 文件 安装setup 漫长,不知道是电脑的原因20多分钟。
https://blog.csdn.net/Embest028/article/details/83141976
2、基础代码
- 显示输入框,换行,其中Chr(13)与 Chr(10)都表示换行。
'在form中双击
Dim var1 As Integer, var2 As String,var3 As Date
var3 = #2/22/2019#
var1 = 12345
var2 = InputBox("输入var2=","输入对话框")
MsgBox(var2 & Chr(13) + Chr(10) & "Var1=" & var1)
- 随机数 代码
Dim x As Integer
x = Int(Rnd() * 100) '随机产生100之内的数
MsgBox(x)
- 日期差异
Dim x, m, y As Integer
x = DateDiff("d", #1/2/2019#, Now) '输入日期与现在的差值 day
m = DateDiff("m", #1/2/2019#, Now) 'month
y = DateDiff("yyyy", #1/2/2019#, Now) 'year
MsgBox(x)
MsgBox(m)
MsgBox(y)
- 变量代码
添加一个button 一个label
Dim intNumber As Integer
intNumber = 27
intNumber = intNumber+1
MessageBox.Show("intNumber=" $ intNumber.ToString)
Label1.Text= intNumber
- double 代码 添加一个button
Dim float_number As Double '注意这里 改成 Integer 查看结果
Dim a As String = "示例"
MsgBox(a, 0, "例子")
float_number = 12.22
float_number = float_number * 12.22
MessageBox.Show("float_number = " & float_number.ToString, "float")
float_number = 12
float_number = float_number / 7
MessageBox.Show("divide=" & float_number.ToString, "float")
- 整型转字符串 添加一个button
Dim a As Integer = 27
Message.Show(a.ToString)
- 字符串长度 添加button
Dim b As String
b = TextBox1.Text
MsgBox(b.Length, 0, "长度")
Dim a As String = "adb"
MessageBox.Show(a.Length)
- 提前 字符数 添加button
Dim a As String = "tom hanks"
MessageBox.Show(a.Substring(0,2))'从第1 个截取两个字符
- format 使用 添加button
Dim a As Double
a = 12 / 7
Message.Show(String.Format("{0:n3}",a))'从第一个参数 开始 ,保留3位浮点数
- replace 添加button
Dim s As String = "hello hello"
Message.Show(s.Replace("hello","Goodbye"))
- date 格式 添加按钮
Dim date1 As Date
date1 = Now
MessageBox.Show(date1.ToString)
MessageBox.Show(date1.ToLongTimeString)
MessageBox.Show(date1.ToShortTimeString)
- sub 使用 过程控制 没有返回值
'编写 sayHello
Private Sub sayHello()
MessageBox.Show("hello world ")
End Sub
' 点击进行调用 可以重用
Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
sayHello()
End Sub
- function的使用 有返回值
Private Function circleArea(ByVal R As Double) As Double
Dim dbR As Double '半径
Dim dbS As Double '面积
dbR = R
dbS = dbR * dbR * Math.PI
Return dbS
End Function
'添加面积
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
Dim S As Double
S = circleArea(5)
MessageBox.Show(S.ToString)
End Sub
- if else
Dim intNumber As Integer = 28
If intNumber = 25 Then
MessageBox.Show("intNumber 的数值" & intNumber)
ElseIf intNumber = 28 Then
MessageBox.Show("intNumber 的数值" & intNumber)
End If
- 流程2
Dim intNumber As Integer
'intNumber = CType(TextBox1.Text, Integer)
intNumber = Val(TextBox1.Text)
If intNumber <= 27 Then
MessageBox.Show("intNumber的值小于等于27", "test")
Else
MessageBox.Show("intNumber的值大于27", "testing")
End If
- stringCompare 忽略大小写
Dim s As String
s = TextBox1.Text
'当设置为true的时候 不区分大小写对比,false的时候 必须 一样一样的才成立
If String.Compare(s, "abcd", True) = 0 Then
MessageBox.Show("hello,you same")
Else
MessageBox.Show("not same")
End If
- select case 的使用
Dim name As String
name = TextBox1.Text
Select Case name
Case "tom"
MsgBox("he is tom")
Case "lily"
MsgBox("she is lily")
Case Else
MsgBox("no name")
3、工具箱
- listBox 的使用
新建listbox 选择item 添加三行数据 a b c 保存 双击 编辑代码
Select Case ListBox1.SelectedItem
Case "a" '点击a 显示a
MessageBox.Show("a")
Case "b"
MessageBox.Show("bbb")
Case "c"
MessageBox.Show("c")
End Select
- 循环 改变listbox
Private Sub clearlist()
ListBox2.Items.Clear() '清空 list内容
End Sub
Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged
Dim i As Integer
clearlist()
For i = 1 To 5
ListBox2.Items.Add("I'am item" & i.ToString & "in the list")
Next
End Sub
- 枚举 添加一个按钮 一个textbox
Private Enum action As Integer
sleep
work
eat
rest
End Enum
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As Integer
a = Int(TextBox1.Text)
If (a > 22 And a < 24) Or (a > 0 And a < 7) Then
MessageBox.Show(action.sleep.ToString)
ElseIf a = 12 Then
MessageBox.Show(action.eat.ToString)
ElseIf a > 19 And a < 22 Then
MessageBox.Show(action.rest.ToString)
Else
If a < 24 Then
MessageBox.Show(action.work.ToString)
Else
MessageBox.Show("error")
End If
End If
End Sub
-
结构体 structure
结构体的建立也可以通过 点击project -添加类 修改class 为student 也可以
Public Structure student
Public name As String
Public gender As String
Public age As String
End Structure
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim objstudent As student
objstudent.name = txtName.Text
objstudent.age = txtAge.Text
objstudent.gender = txtGender.Text
MessageBox.Show("学生的信息为:" & vbCrLf & objstudent.name & vbCrLf & objstudent.gender & vbCrLf & objstudent.age, "student info") 'vbcrlf 换行符
End Sub
- 结构化属性
Public Structure name1
Public 姓 As String
Public 名 As String
Public ReadOnly Property 姓名() As String
Get
Return 姓 & 名
End Get
End Property
End Structure
Private Sub nameBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles nameBtn.Click
Dim objname As name1
objname.姓 = txt姓.Text
objname.名 = txt名.Text
MessageBox.Show("学生的姓名是:" & vbCrLf & objname.姓名, "姓名")
End Sub
备注
找不到 Microsoft.office.interop.Excel 找了两天不知道怎么回事
最后 两步
- 下载 https://www.cnblogs.com/top5/archive/2010/03/12/1684559.html
- 删除 原来引用的interop.excel,重新添加引用,使用 浏览进行文件的添加
- 树莓派 魔镜 天气模块
{
module: "weatherforecast",
position: "top_right",
header: "Weather Forecast",
config: {
lang:"zh_CN",
location: "Beijing",
locationID: "2038349", //ID from https://openweathermap.org/city
appid: "6f86fb7b6800bf8e3c5f0f62a454324f"
}
},
在加入remote的时候一直报错,折腾了好几天,原来
:
-
https://github.com/Jopyth/MMM-Remote-Control
作者少了一个逗号 ,添加的时候一直报错,怀疑人生; - 端口号 被占用 到处修改端口 最后 修改白名单 我靠,一直改错,最后干脆 全部允许
终于出现了 在多个设备登录到了