我想在运行时在Excel中使用VBA添加一个Control和一个关联的事件,但我不知道如何添加事件.
我尝试了下面的代码,并且在我的userform中正确创建了Button,但是应该显示hello消息的关联click事件不起作用.
任何建议/更正都会受到欢迎.
Dim Butn As CommandButton
Set Butn = UserForm1.Controls.Add("Forms.CommandButton.1")
With Butn
.Name = "CommandButton1"
.Caption = "Click me to get the Hello Message"
.Width = 100
.Top = 10
End With
With ThisWorkbook.VBProject.VBComponents("UserForm1.CommandButton1").CodeModule
Line = .CountOfLines
.InsertLines Line + 1, "Sub CommandButton1_Click()"
.InsertLines Line + 2, "MsgBox ""Hello!"""
.InsertLines Line + 3, "End Sub"
End With
UserForm1.Show
Run Code Online (Sandbox Code Playgroud) 我想更改postgresql.conf文件中的"shared_buffers"参数.
问题是我使用了sudo命令,它将所有权赋予root.
-rw-rw-rw- 1 root root 13661 Mar 14 15:36 postgresql.conf
Run Code Online (Sandbox Code Playgroud)
然后我使用以下命令将所有权归还给postmaster:
sudo chown postgres:postgres /var/lib/pgsql/data/postgresql.conf
Run Code Online (Sandbox Code Playgroud)
所以我尝试了这个命令:
postgres -D /var/lib/pgsql/data
Run Code Online (Sandbox Code Playgroud)
我仍然感到非常惊讶,仍然收到以下错误消息
postgres cannot access the server configuration file "/var/lib/pgsql/data/postgresql.conf": Permission denied
Run Code Online (Sandbox Code Playgroud)
下面的id是postgreSQL中目录中"ls"命令的结果:
sudo ls -l /var/lib/pgsql/data/
total 208
drwx------ 19 postgres postgres 4096 Mar 13 17:23 base
drwx------ 2 postgres postgres 4096 Mar 14 14:30 global
drwx------ 2 postgres postgres 4096 Mar 5 14:26 pg_clog
-rw------- 1 postgres postgres 3365 Mar 1 2006 pg_hba.conf
-rw------- 1 postgres postgres 3182 Mar …Run Code Online (Sandbox Code Playgroud)