openFileOpen "c:\sample.txt" For Input As #1   唔明For Input As #1????  #1係咩來?Input #1, variable1   這句係唔係講 Input=variable(變數)?Text1.Text = variable1 Close #1 點解要終止#1saveFilePrivate Sub Command1_Click   Dim hFile as Long    ??? 
   Dim sFilename as String    ??   sFilename = "c:\demo.txt"
   
   hFile = FreeFile       ????
   Open sFilename For Output As #hFile     ???
      Print #hFile, Text1.Text   ???????
   Close #hFile        ???
  
End Sub(Index As Integer)點解?
VB寫MSComm1.Output & MSComm1.Input Delay點寫??因為本用來send 0 1 2 3 4 to rs232 到8051但如果我按11我8051果到就收到唔知咩來所以我就想加個Delay各位高手可以幫幫手

解决方案 »

  1.   

    Open "c:\sample.txt" For Input As #1   唔明For Input As #1????  #1係咩來?    //#1是你当前操作的文件号。Input #1, variable1   這句係唔係講 Input=variable(變數)?//这个意思是你把#1文件里面的内容读到variable1里面Text1.Text = variable1  Close #1 點解要終止#1 //操作号了关闭#1文件(Index As Integer)點解? //标示参数为int的index
      

  2.   

    Dim st As String 點解?在Text入 Low So 在 hypertrm 收到係0但我入Low SoLow So#在 hypertrm 收到係Low SoLow So#我要點寫先出到01???
    Low SoLow So#Low SoPrivate Sub SEND_DATA_Click()
      Dim st As String
    st = Text_send.Text
     Select Case st
      Case "Low So"
        st = "0"
      Case "Low So#"
        st = "1"
      Case "MLow LA"
         st = "2"
      Case "Low LA#"
        st = "3"
      Case "Low TI"
         st = "4"
      Case "Mid Do"
         st = "5"
         End Select
         
      Text_send.Text = st
      If MSComm1.PortOpen = True Then MSComm1.Output = Text_send.Text
    End Sub
      

  3.   

    我在VB Text 入 數字eg.123     MSComm1.Output  出去用終端機( Hypertrm )收到就係123了 1=Do 2=Re 3=Fa 4=Mo 5=So
    但我想改成以下Low SoLow So#Low SoPrivate Sub SEND_DATA_Click() 
      Dim st As String 
    st = Text.Text 
    Select Case st 
      Case "Do" 
        st = "1" 
      Case "Re" 
        st = "2" 
      Case "Fa" 
         st = "3" 
      Case "Mo"
        st = "4" 
       Case "So" 
        st = "5" 
         End Select 
          
      Text.Text = st 
      If MSComm1.PortOpen = True Then MSComm1.Output = Text.Text
     End Sub
    Text 入 Do左終端機( Hypertrm )收到就係1 但我入DoRe左終端機( Hypertrm )收到就係DoRe出唔到12
      

  4.   

    你是不是想将Do、Re、Mo...转换成123并Output啊?可是当你输入DoRe时,你的代码只转换了第一个,你应该使用循环,比如:
    dim st1 as string,st2 as string
    st1=Trim(Text.Text)
    for i=1 to len(st1)
        st2=st2 & cstr(instr(st1,mid(st1,i,2)+1)/2)
    next
    if mscomm1.portopen=true and len(st2)>0 then mscomm1.output=st2需要注意的是,text.text中不能包含空格,否则结构不准确。
      

  5.   

    dim st1 as string,st2 as string 
    st1=Trim(Text.Text) 
    for i=1 to len(st1) 
        st2=st2 & cstr(instr(st1,mid(st1,i,2)+1)/2) 
    next 
    if mscomm1.portopen=true and len(st2)>0 then mscomm1.output=st2 
    用唔到出error---- st2=st2 & cstr(instr(st1,mid(st1,i,2)+1)/2) ????????????
      

  6.   

    错了,在循环时步长应为2,如下:
    for i=1 to len(st1) step 2
      

  7.   

    出到但入1`2`3Output出來係000??入英文字又出error