Skip to main content

AccessTr.neT


Telefon Rehberi

Telefon Rehberi

#7
telefon çevirisini açmadan telefon numarası çevirme kodu
Kod:
Function DialNumber(PhoneNumber, CommPort As String)
      ' PURPOSE: To dial a telephone number using the computer's modem
      ' ARGUMENTS:
      '    PhoneNumber: The telephone number to dial
      '    CommPort: The communications port the modem is connected
      '              to. Typically, modems are found on COM2, however,
      '              they can be configured for any COM port.
      '
      ' EXAMPLE:
      '    Type the following in the Immediate window using a modem
      '    connected to the COM2 port:
      '
      '       ? DialNumber("555-1212", "COM2")
      '
      ' ***********************************************************

         Dim MSG As String, MsgBoxType As Integer, MsgBoxTitle As String
         Dim bModemCommand(256) As Byte, ModemCommand As String
         Dim OpenPort As Long
         Dim retval As Long, RetBytes As Long, i As Integer
         Dim StartTime

        
        

         ' Open the communications port for read/write (&HC0000000).
         ' Must specify existing file (3).
         OpenPort = CreateFile(CommPort, &HC0000000, 0, 0, 3, 0, 0)
         If OpenPort = -1 Then
            MSG = "Unable to open communication port " & CommPort
            GoTo Err_DialNumber
         End If

         ' Send the telephone number to the modem.
         ModemCommand = "ATDT" & PhoneNumber & vbCrLf
         ' Pack the string in a Byte array.
         For i = 0 To Len(ModemCommand) - 1
            bModemCommand(i) = Asc(Mid(ModemCommand, i + 1, 1))
         Next

         ' Write the string to the Com port.
         retval = WriteFile(OpenPort, bModemCommand(0), _
            Len(ModemCommand), RetBytes, 0)
         If retval = 0 Then
            MSG = "Unable to dial number " & PhoneNumber
            GoTo Err_DialNumber
         End If

         ' Flush the buffer to make sure it actually wrote
         retval = FlushFileBuffers(OpenPort)

         ' Wait WAITSECONDS seconds for the phone to dial.
         StartTime = Timer
         While Timer < StartTime + WAITSECONDS
            DoEvents
         Wend

         ' Reset the modem and take it off line.
         ModemCommand = "ATH0" & vbCrLf
         ' Pack the byte array again.
         For i = 0 To Len(ModemCommand) - 1
            bModemCommand(i) = Asc(Mid(ModemCommand, i + 1, 1))
         Next
         retval = WriteFile(OpenPort, bModemCommand(0), _
            Len(ModemCommand), RetBytes, 0)

         'Flush the buffer again.
         retval = FlushFileBuffers(OpenPort)

         ' Close the communications port.
         retval = CloseHandle(OpenPort)

         Exit Function

Err_DialNumber:            'This is not an On Error routine.
         MSG = MSG & vbCr & vbCr & _
            "Make sure no other devices are using Com port " & CommPort
         MsgBoxType = MB_ICONSTOP
         MsgBoxTitle = "Dial Number Error"
         MsgBox MSG, MsgBoxType, MsgBoxTitle

    End Function

formdaki düğmeye ekleyin
Kod:
Call DialNumber(me.telefonnumarasınınkutusu, "COM3")
COM3 yazan yere modeminizin protunu yazın
Son Düzenleme: 01/11/2008, 17:19, Düzenleyen: esrefigit.
Cevapla
#8
paylaşım için çok teşekkürler. benim gibi yeni başlayanlar için güzel bir örnek.
Cevapla
#9
Teşekkürler
Cevapla
#10
paylaşım için teşekkürler
Cevapla
#11
teşekkürler dostum
Cevapla
#12
örnek için teşekürler
Cevapla

Bir hesap oluşturun veya yorum yapmak için giriş yapın

Yorum yapmak için üye olmanız gerekiyor

ya da
Task