以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- VB.NET如何转狐表? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=190823) |
|
-- 作者:lin98 -- 发布时间:2024/3/6 12:25:00 -- VB.NET如何转狐表? \'Imports System.Diagnostics \'Public Class Form1 Private Sub Button_Backup_Click(sender As Object, e As EventArgs) Handles Button_Backup.Click Dim processInfo As New ProcessStartInfo() processInfo.FileName = "mysqldump"\' processInfo.Arguments += "-u yourUsername" processInfo.Arguments += "-p" processInfo.Arguments += "--host=yourHostname" processInfo.Arguments += "--port=yourPortNumber" processInfo.Arguments += "--databases databaseName" processInfo.Arguments += "> backupFilePath" Using process As New Process() With {.StartInfo = processInfo } process.Start() process.WaitForExit() End Using MessageBox.Show("完成!") End Sub \'End Class 红代码,报错不能在主体内。VB.NET如何转狐表? |
|
-- 作者:有点蓝 -- 发布时间:2024/3/6 13:55:00 -- 放到全局代码 public Sub Button_Backup_Click(sender As Object, e As System.EventArgs) Dim processInfo As New System.Diagnostics.ProcessStartInfo() processInfo.FileName = "mysqldump"\' processInfo.Arguments += "-u yourUsername" processInfo.Arguments += "-p" processInfo.Arguments += "--host=yourHostname" processInfo.Arguments += "--port=yourPortNumber" processInfo.Arguments += "--databases databaseName" processInfo.Arguments += "> backupFilePath" Using process As New Process() With {.StartInfo = processInfo } process.Start() process.WaitForExit() End Using MessageBox.Show("完成!") End Sub |
|
-- 作者:lin98 -- 发布时间:2024/3/6 19:31:00 -- 问题一:VB.NET代码转狐表,都要全局代码? 问题二:二楼代码放到全局代码,如何实现窗口 上按键来调用? processInfo.Arguments += "-u yourUsername" processInfo.Arguments += "-p" processInfo.Arguments += "--host=yourHostname" processInfo.Arguments += "--port=yourPortNumber" processInfo.Arguments += "--databases databaseName" processInfo.Arguments += "> backupFilePath" 红代码,是不是可用窗口的文本框的值? 窗口1-文本框1 ="-u yourUsername" 窗口1-文本框2 ="-p" 、、、、、、 按键单击执行? |
|
-- 作者:有点蓝 -- 发布时间:2024/3/7 8:41:00 -- 去掉【public Sub ...】这行,剩下其它代码可以放到按钮里 |
|
-- 作者:lin98 -- 发布时间:2024/3/7 13:45:00 -- \'\'\'Imports System.IO \'\'\'Imports MySql.Data.MySqlClient \'\'\'Imports System.Security.Cryptography \'\'Public Class Form1 \' Private WithEvents timer As New Timer() \' \' Public Sub New() \' InitializeComponent() \' \' timer.Interval = TimeSpan.FromMinutes(30).TotalMilliseconds \' \' timer.Enabled = True \' \' End Sub \' Private Sub BackupAndEncryptDatabase() \' Dim connectionString As String = "server=localhost;user id=root;password=your_password;database=your_database" \' Dim backupPath As String = Path.Combine("", DateTime.Now.ToString("yyyyMMddHHmmss") & ".sql") \' Using conn As New MySqlConnection(connectionString) \' conn.Open() \' \' Dim cmd As New MySqlCommand($"mysqldump --opt -u root -p your_password {conn.Database} > \'{backupPath}\'", conn) \' cmd.ExecuteNonQuery() \' \' 关闭连接 \' conn.Close() \' End Using \' End Sub \' Private Sub EncryptFile(filePath As String) \' Using aesAlg As Aes = Aes.Create(), \' encryptor As ICryptoTransform = aesAlg.CreateEncryptor(key, iv) \' Using csEncrypt As CryptoStream = New CryptoStream(fsOutput, encryptor, CryptoStreamMode.Write) \' \' fsInput.CopyTo(csEncrypt) \' End Using \' End Using \' End Using \' End Sub \'\'End Class ---------------------------------------------- 问题一:上面代码VB.NET如何转狐表?放在全局代码或窗口上的按键单击事件都不行,红代码报错缺少关键词,局部变量出错 问题二:VB.NET都导入一些包,类,这些如何在狐表引用? \'\'Imports System.IO \'\'\'Imports MySql.Data.MySqlClient \'\'\'Imports System.Security.Cryptography 问题三:VB.NET的这些Public、private、protected的空间,类,事件如何转狐表?是否有固定语法或格式? 问题四:狐表说是VB.NET开发,VB.NET的代码不能直接用,还转,让小白很难受,能否改进一下? 官方能否出个视频讲解一下,狐表如何套用VB.NET的代码?狐表特殊在网上是找不到此类教程,只能官方 来教,狐表也要编码,很多用户在狐表不找方法,会在网上VB.NET的代码参用。很多用户都会有需要, 希望官方教程。
|
|
-- 作者:有点蓝 -- 发布时间:2024/3/7 14:02:00 -- 1、除了前3行,启动代码都保留放到全局代码 2、不需要引用,直接把命名空间补齐到函数代码里即可,比如 Using conn As New MySql.Data.MySqlClient.MySqlConnection(connectionString) 3、如果是定义到class的,照样放到全局代码即可,看第2点,如果只是单独定义函数,函数必须使用Public 4、没有办法也不可能完全照vs的用法。只能按前面3点转换使用 如果真的懂vs开发,还不如直接在vs开发做成dll给foxtable调用。
|
|
-- 作者:lin98 -- 发布时间:2024/3/7 14:58:00 -- \'Imports System.IO \'Imports MySql.Data.MySqlClient \'Imports System.Security.Cryptography \'Public Class Form1 问题一 5楼代码去除红代码后,全局代码,报错Public Sub New(),提示共享Sub New(),不能声明Public,改Private也一样报错 Public Sub New() 问题二
问题三:5楼代码,下面代码,报错未定义类型FileStream Using fsInput As FileStream = New FileStream(filePath, FileMode.Open), [此贴子已经被作者于2024/3/7 15:10:57编辑过]
|
|
-- 作者:有点蓝 -- 发布时间:2024/3/7 15:29:00 -- 1、都说了只去掉前3行,Public Class Form1 不要去掉 2、3:都说了要补齐命名空间: System.IO.Path.Combine System.IO.FileStream 如果不懂什么是命名空间,先百度学习一下
|
|
-- 作者:lin98 -- 发布时间:2024/3/9 13:26:00 -- using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Diagnostics; namespace lxw_mysql_helper { public partial class frmMain : Form { public frmMain() { InitializeComponent(); } public String bakpath = @"D:\\db_bak\\"; private void frmMain_Load(object sender, EventArgs e) { txtName.Enabled = false; public static void RunCMD(String workingDirectory, String command) { Process p = new Process(); public void bakup_db(string manual = "") { try { public void recovery_db() { try { private void btnBackUp_Click(object sender, EventArgs e) { bakup_db("manual"); } private void btnSelectMysqlPath_Click(object sender, EventArgs e) { FolderBrowserDialog path = new FolderBrowserDialog(); if (!string.IsNullOrEmpty(txtMysqlPath.Text)) { path.SelectedPath = txtMysqlPath.Text; } path.ShowDialog(); txtMysqlPath.Text = path.SelectedPath; } private void btnEdit_Click(object sender, EventArgs e) { if (btnEdit.Text == "修改") { txtName.Enabled = true; txtPwd.Enabled = true; btnEdit.Text = "确定"; } else if (btnEdit.Text == "确定") { uname = txtName.Text; upass = txtPwd.Text; backupTime = txtBackUpTime.Text; DateTime temp; if (!DateTime.TryParse(backupTime, out temp)) { ShowLog("备份时间格式错误,重置时间为00:30"); txtBackUpTime.Text = "00:30"; backupTime = txtBackUpTime.Text; } ShowLog("修改成功!"); MessageBox.Show("修改成功!"); btnEdit.Text = "修改"; txtName.Enabled = false; txtPwd.Enabled = false; } 上面是去掉粉红代码,放在全局代码里,红代码,试着先方法,改还是报错如何解决? |
|
-- 作者:有点蓝 -- 发布时间:2024/3/9 14:08:00 -- c#转vb:https://converter.telerik.com/ 全部代码先转换,在考虑去掉多余的代码
|