Dim sFilePath As String
On Error Resume Next
Call GetRegistryParam("ConfStorePath", CommonCondition.ConfStorePath)
sFilePath = CommonCondition.ConfStorePath + "\COMMON_COND.TXT"
//上面通過註冊表保存的路徑打開一個文件 Open sFilePath For Input As #1
//如果這個文件不存在,會走這個if嗎?
If Err.Number <> 0 Then
Text1(3).Text = App.Path
Text1(4).Text = App.Path
Exit Sub
End If
//下面的這塊是我問題的關鍵
With CommonCondition
Input #1, .MailServerIP
Input #1, .ReceiverEMailAddress
Input #1, .MailSenderName
Input #1, .LogStorePath
End With
Close #1
//我的目的就是把.LogStorePath賦值給Text1(3).Text,該怎麽實現?
Text1(3).Text = .LogStorePath
Text1(4).Text = CommonCondition.ConfStorePath
On Error Resume Next
Call GetRegistryParam("ConfStorePath", CommonCondition.ConfStorePath)
sFilePath = CommonCondition.ConfStorePath + "\COMMON_COND.TXT"
//上面通過註冊表保存的路徑打開一個文件 Open sFilePath For Input As #1
//如果這個文件不存在,會走這個if嗎?
If Err.Number <> 0 Then
Text1(3).Text = App.Path
Text1(4).Text = App.Path
Exit Sub
End If
//下面的這塊是我問題的關鍵
With CommonCondition
Input #1, .MailServerIP
Input #1, .ReceiverEMailAddress
Input #1, .MailSenderName
Input #1, .LogStorePath
End With
Close #1
//我的目的就是把.LogStorePath賦值給Text1(3).Text,該怎麽實現?
Text1(3).Text = .LogStorePath
Text1(4).Text = CommonCondition.ConfStorePath
//这里加上这句能保证走下面的 IF 语句
On Error Resume Next
Open sFilePath For Input As #1
//如果這個文件不存在,會走這個if嗎?
//下面的這塊是我問題的關鍵
With CommonCondition
Input #1, .MailServerIP
Input #1, .ReceiverEMailAddress
Input #1, .MailSenderName
Input #1, .LogStorePath
End With
Close #1
//我的目的就是把.LogStorePath賦值給Text1(3).Text,該怎麽實現?
Text1(3).Text = .LogStorePath
Text1(4).Text = CommonCondition.ConfStorePath大概是怎麽個意思?
应该改为Text1(3).Text = CommonCondition.LogStorePath才行
你的With语句已经结束了,所以要写全,像你下一行一样
好像是dir()之类的,我曾经用过
現在有個程序界面是vb做的
命令行程序是vc做的
界面程序要有點改動
知道改動的思路
但不知道方法
並且特別急
請大家多幫幫忙
多挣鬼子钱
Dim sFilePath As String
On Error Resume Next
Call GetRegistryParam("ConfStorePath", CommonCondition.ConfStorePath)
sFilePath = CommonCondition.ConfStorePath + "\COMMON_COND.TXT"
//上面通過註冊表保存的路徑打開一個文件 Open sFilePath For Input As #1
//如果這個文件不存在,会走这个if吗?
//我查看vb帮助,好像不是不存在这个文件,走这一步,若不存在,会创建新文件。
//我的目的是在这个文件不存在的时候,走这个if,该怎么实现??????????????
If Err.Number <> 0 Then
Text1(3).Text = App.Path
Text1(4).Text = App.Path
//这一步我还想追加:创建一个新的文件,然后往文件里写Text1(3).Text 和Text1(4).Text
Exit Sub
End If
//下面的這塊是我問題的關鍵
With CommonCondition
Input #1, .MailServerIP
Input #1, .ReceiverEMailAddress
Input #1, .MailSenderName
Input #1, .LogStorePath
End With
Close #1
//我的目的就是把.LogStorePath賦值給Text1(3).Text,該怎麽實現?
Text1(3).Text = .LogStorePath
Text1(4).Text = CommonCondition.ConfStorePath