Results 1 to 6 of 6

Thread: Syntax error

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    13

    Syntax error

    This is the code I am trying to use
    vb Code:
    1. Private Sub cmdTryIt_Click()
    2.  
    3.     Dim strEmpFileName As String
    4.     Dim strBackslash   As String
    5.     Dim intEmpFileNbr  As Integer
    6.     Dim strEmpName     As String
    7.     Dim intDeptNbr     As Integer
    8.     Dim strJobTitle    As String
    9.     Dim dtmHireDate    As Date
    10.     Dim sngHrlyRate    As Single
    11.    
    12.     strBackslash = IIf(Right$(App.Path, 1) = "\", "", "\")
    13.     strEmpFileName = App.Path & strBackslash & "EMPLOYEE.Dat"
    14.     intEmpFileNbr = FreeFile
    15.    
    16.     Open strEmpFileName For Append As #intEmpFileNbr
    17.    
    18.     strEmpName = ("Enter Name (Or click Cancel to stop):")
    19.      
    20.      
    21.      
    22.      Do Until strEmpName = ""
    23.      
    24.      intDeptNbr = InputBox("Enter Debt:")
    25.      strJobTitle = InputBox("Enter Job Title:")
    26.      dtmHireDate = InputBox("Enter Hire Date:")
    27.      sngHrlyRate = InputBox("Enter Hourly Rate:")
    28.      
    29.      Write #intDeptNbr, strEmpName, strJobTitle, dtmHireDate, sngHrlyRate,
    30.      
    31.      Print strEmpName; _
    32.             Tab(25); Format$(intDebtNbr, "@@@@"); _
    33.             Tab(35); strJobTitle; _
    34.             Tab(60); Format$(intDebtNbr, "mm/dd/yyyy); _
    35.             Tab(71); Format$(Format$(sngHrlyRate, "Standard"), "@@@@@@@")
    36.            
    37.         strEmpName = InputBox("Enter name (or click Cancel to stop):")
    38.     Loop
    39.     Close #impEmpFileNbr
    40.    
    41.            
    42.  
    43. End Sub


    WHenever I try to run the program error pops up, I receive a syntax error. Can anyone help me understand why I keep getting an error?
    Last edited by Hack; Mar 29th, 2012 at 12:39 PM. Reason: Added Highlight Tags

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Syntax error

    Moved From The CodeBank (which is for sharing code rather than posting questions )

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    13

    Re: Syntax error

    ATTENTION : I am not sandyravage! That peron is in the same class as me and I guess we decided to post the same problem.
    Last edited by mrf0272; Mar 29th, 2012 at 01:08 PM.

  4. #4
    Wall Poster TysonLPrice's Avatar
    Join Date
    Sep 2002
    Location
    Columbus, Ohio
    Posts
    3,969

    Re: Syntax error

    Quote Originally Posted by mrf0272 View Post
    This is the code I am trying to use
    vb Code:
    1. Private Sub cmdTryIt_Click()
    2.  
    3.     Dim strEmpFileName As String
    4.     Dim strBackslash   As String
    5.     Dim intEmpFileNbr  As Integer
    6.     Dim strEmpName     As String
    7.     Dim intDeptNbr     As Integer
    8.     Dim strJobTitle    As String
    9.     Dim dtmHireDate    As Date
    10.     Dim sngHrlyRate    As Single
    11.    
    12.     strBackslash = IIf(Right$(App.Path, 1) = "\", "", "\")
    13.     strEmpFileName = App.Path & strBackslash & "EMPLOYEE.Dat"
    14.     intEmpFileNbr = FreeFile
    15.    
    16.     Open strEmpFileName For Append As #intEmpFileNbr
    17.    
    18.     strEmpName = ("Enter Name (Or click Cancel to stop):")
    19.      
    20.      
    21.      
    22.      Do Until strEmpName = ""
    23.      
    24.      intDeptNbr = InputBox("Enter Debt:")
    25.      strJobTitle = InputBox("Enter Job Title:")
    26.      dtmHireDate = InputBox("Enter Hire Date:")
    27.      sngHrlyRate = InputBox("Enter Hourly Rate:")
    28.      
    29.      Write #intDeptNbr, strEmpName, strJobTitle, dtmHireDate, sngHrlyRate,
    30.      
    31.      Print strEmpName; _
    32.             Tab(25); Format$(intDebtNbr, "@@@@"); _
    33.             Tab(35); strJobTitle; _
    34.             Tab(60); Format$(intDebtNbr, "mm/dd/yyyy); _
    35.             Tab(71); Format$(Format$(sngHrlyRate, "Standard"), "@@@@@@@")
    36.            
    37.         strEmpName = InputBox("Enter name (or click Cancel to stop):")
    38.     Loop
    39.     Close #impEmpFileNbr
    40.    
    41.            
    42.  
    43. End Sub


    WHenever I try to run the program error pops up, I receive a syntax error. Can anyone help me understand why I keep getting an error?
    You need a quote here:

    "mm/dd/yyyy")

  5. #5
    Fanatic Member sessi4ml's Avatar
    Join Date
    Nov 2006
    Location
    Near San Francisco
    Posts
    958

    Re: Syntax error

    You are missing the file pointer.
    What record within the file are you pointing to ...zero (0).. I guess

  6. #6

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    13

    Re: Syntax error

    Thanks I can't believe I missed that. I guess I dindn't check over my code well enough. I fixed that part now and now whenever I put in the data it asks me It seems to have a prblem with line 29 of the code. (It says Run-time error '13' Type mismatch). I really appreciate the help

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width