Results 1 to 8 of 8

Thread: Option Strict - Issues

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2006
    Location
    Florida, USA
    Posts
    565

    Option Strict - Issues

    I turned on Option Strict, but I have a few issues that I am not sure the best way to handle.

    We leave the speech object as an object because some systems do not support speech and this is the only way we knew how to detect the issue. Any better ideas?

    vb Code:
    1. Public speech As Object = Nothing 'SpeechLib.SpVoice
    I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: Option Strict - Issues

    leave options strict on as the default setting, then in the class/module/what ever where you're using the speech object, turn it off.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2006
    Location
    Florida, USA
    Posts
    565

    Re: Option Strict - Issues

    What do you recommend for this? I tried to change Object to Radio Button on the function header but it did not help.

    error Code:
    1. Error   9   Option Strict On disallows late binding.    C:\Users\Jeff\Documents\JeffWorkSpace2\StudyX.NET\frmStudy.vb   1020    16  study

    vb Code:
    1. Private Sub _uotAnswer_0_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles rbOption1.KeyPress, rbOption2.KeyPress, rbOption3.KeyPress, rbOption4.KeyPress
    2.  
    3.         If e.KeyChar = Chr(Keys.Return) Then 'Microsoft.VisualBasic.ChrW(Keys.Return)
    4.             If sender.Checked = True Then
    5.                 btnNext_Click(sender, e)
    6.             End If
    7.         End If
    8.  
    9.  
    10.     End Sub
    I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.

  4. #4
    Karen Payne MVP kareninstructor's Avatar
    Join Date
    Jun 2008
    Location
    Oregon
    Posts
    6,713

    Re: Option Strict - Issues

    Quote Originally Posted by rex64 View Post
    What do you recommend for this? I tried to change Object to Radio Button on the function header but it did not help.

    error Code:
    1. Error   9   Option Strict On disallows late binding.    C:\Users\Jeff\Documents\JeffWorkSpace2\StudyX.NET\frmStudy.vb   1020    16  study

    vb Code:
    1. Private Sub _uotAnswer_0_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles rbOption1.KeyPress, rbOption2.KeyPress, rbOption3.KeyPress, rbOption4.KeyPress
    2.  
    3.         If e.KeyChar = Chr(Keys.Return) Then 'Microsoft.VisualBasic.ChrW(Keys.Return)
    4.             If sender.Checked = True Then
    5.                 btnNext_Click(sender, e)
    6.             End If
    7.         End If
    8.  
    9.  
    10.     End Sub
    Here is how you should do this, knowing the event only handles RadioButton controls cast sender as a RadioButton, test for enter pressed and if so invoke PerformClick method for the Button.
    Code:
    Private Sub RadioButton1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _
        Handles RadioButton1.KeyPress, RadioButton2.KeyPress
    
        If e.KeyChar = Microsoft.VisualBasic.ChrW(Keys.Return) Then
            If CType(sender, RadioButton).Checked Then
                Button1.PerformClick()
            End If
        End If
    
    End Sub

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Option Strict - Issues

    The obvious solution is to use the Speech API built into the .NET Framework instead of the old Windows SAPI. .NET has provided its own Speech API since version 3.0. If you use that you know that every application that runs your app will support it because it must have the correct Framework installed.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2006
    Location
    Florida, USA
    Posts
    565

    Re: Option Strict - Issues

    I am using .NET 2.0 because I want to maximize compatibility.
    I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Option Strict - Issues

    Isn't that a little ironic given that you started this thread in the first place due to a compatibility issue? .NET 3.0 is supported on XP SP2 and Windows Server 2003 SP1. How much more compatibility do you want?
    Last edited by jmcilhinney; Jul 2nd, 2012 at 08:56 PM.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2006
    Location
    Florida, USA
    Posts
    565

    Re: Option Strict - Issues

    Good point, I think it is almost time to phase out 98 and SP1 . Our software is used in countries where people can not afford new computers, and we don't want to exclude them, but I think most people can do XP SP2 at least.
    I use VB .NET 2022. Currently developing StudyX educational software, PlazSales POS system and Yargis a space ship shooter game.

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