| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 886 人关注过本帖
标题:请问文本框内容如何再显
取消只看楼主 加入收藏
jrs123
Rank: 2
等 级:论坛游民
威 望:1
帖 子:627
专家分:14
注 册:2006-9-5
收藏
得分:0 
回复 16楼 jrs123
一个可以通过的方案:谢谢这一高手的代码:
Option Explicit '快手改——1

Private Declare Function GetPrivateProfileInt Lib "kernel32" Alias "GetPrivateProfileIntA" _
(ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal nDefault As Long, ByVal _
lpFileName As String) As Long

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" _
(ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal _
lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" _
(ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName _
As String) As Long

Dim tags As Integer
Dim FN As String
Dim temp_a As String, temp_b As String, temp_c As String, temp_d As String
Dim t1 As String, t2 As String, t3 As String, t4 As String

Private Function IsFileExist(strFileName As String) As Boolean '快手改——2
    Dim varFSO As Variant
    Set varFSO = CreateObject("Scripting.FileSystemObject")
    IsFileExist = varFSO.FileExists(strFileName)
    Set varFSO = Nothing
End Function

Private Sub Form_Initialize() '快手改——3
  FN = "my.txt"
End Sub

Private Sub Form_Load() '快手改——4
    If IsFileExist(FN) = True Then
        Call ReadData
    End If
    Text1.Text = t1
    Text2.Text = t2
    Text3.Text = t3
    Text4.Text = t4
End Sub

Private Sub text1_click() '快手改——5
  tags = 1
  Call myInput(tags)
End Sub

Private Sub Text2_click() '快手改——6
  tags = 2
  Call myInput(tags)
End Sub

Private Sub Text3_click() '快手改——7
  tags = 3
  Call myInput(tags)
End Sub

Private Sub Text4_click() '快手改——8
   tags = 4
   Call myInput(tags)
End Sub

'如下接收输入函数
Private Sub myInput(tags As Integer) '快手改——9

'获取输入
Dim message, title, defaultValue As String
Dim myValue As String
message = "请输入你的留言" '设置提示信息
title = "InputBox Demo" '设置标题
defaultValue = "" '设置默认值
myValue = InputBox(message, title, defaultValue, 100, 100)
'显示输入对话框

'判断并处理(保存)输入

If myValue = "" Then
   MsgBox "没有输入任何内容!", vbInformation + vbOKOnly, "提示"
Else
   '保存输入,留言间用特殊标示“||”隔开,不用逗号是因为留言中可能包含逗号,故尽可能避免分拆时错误
   
   '读出原始内容
   Call ReadData
   
   '合并保存并显示
   Call WriteData(tags, myValue)
   
End If

End Sub


'如下读取数据函数
Private Sub ReadData() '快手改——10

  temp_a = GetINI(FN, "GueseBook", "No1")
  temp_b = GetINI(FN, "GueseBook", "No2")
  temp_c = GetINI(FN, "GueseBook", "No3")
  temp_d = GetINI(FN, "GueseBook", "No4")
  t1 = Mid(temp_a, 1, InStr(temp_a, "||") - 1)
  t2 = Mid(temp_b, 1, InStr(temp_b, "||") - 1)
  t3 = Mid(temp_c, 1, InStr(temp_c, "||") - 1)
  t4 = Mid(temp_d, 1, InStr(temp_d, "||") - 1)
  
End Sub


'如下保存数据函数
Private Sub WriteData(tags As Integer, myValue As String) '快手改——11

   Call ReadData
   Select Case tags
      Case 1
         WritePrivateProfileString "GueseBook", "No1", myValue & "||" & temp_a, App.Path & "\" & FN
         Text1.Text = myValue
      Case 2
         WritePrivateProfileString "GueseBook", "No2", myValue & "||" & temp_b, App.Path & "\" & FN
         Text2.Text = myValue
      Case 3
         WritePrivateProfileString "GueseBook", "No3", myValue & "||" & temp_c, App.Path & "\" & FN
         Text3.Text = myValue
      Case 4
         WritePrivateProfileString "GueseBook", "No4", myValue & "||" & temp_d, App.Path & "\" & FN
         Text4.Text = myValue
   End Select
   
End Sub


'如下INI文件读取函数
Public Function GetINI(ByRef inifile As String, ByVal section As String, ByVal key As String, Optional ByVal defvalue As String = vbNullString) As String '快手改——12
  'inifile INI文件名, section 段落,key 关键字,defvalue 值
  Dim thisQU1 As String
  Dim QU1 As Long
  thisQU1 = Space$(256) '事先定义读取的字串宽度
  QU1 = GetPrivateProfileString(section, key, defvalue, thisQU1, 255, App.Path & "\" & inifile)
  GetINI = Left$(thisQU1, Len(Trim$(thisQU1)) - 1)         '名称
End Function
2012-11-23 11:52
jrs123
Rank: 2
等 级:论坛游民
威 望:1
帖 子:627
专家分:14
注 册:2006-9-5
收藏
得分:0 
回复 17楼 ccwu2
请高手测试通过改后发包可以吗?
2012-11-23 11:54
快速回复:请问文本框内容如何再显
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.032723 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved