none
Small Basic Extension RRS feed

  • Question

  • Hi! I am toying around with VB .dll's for SB extensions and I have just made a VERY SIMPLE speech one. Now I am going to make a simple network extension, and I need the extension to return a value if network is available. I know how to check if network is available, but I do not know how to make the extension return "True" or "False". I code in VB, but I can use a translator. Thank you for any help.
    Friday, August 10, 2012 8:16 PM

Answers

  • XML Documents are useless if you don't have any XML comments in your extension...

    Change NotInheritable Class into Module. What kind of tutorial have you been following here ^^

    Also Namespaces aren't required, trust me, I have no namespace structure in my extension...
    Friday, August 10, 2012 10:12 PM

All replies

  • It's pretty simple you just have to play with conditions...

    If My.Computer.Network.IsAvaliable = True Then

    Return "True"

    Else

    Return "False"

    End If

    Friday, August 10, 2012 8:30 PM
  • 


    Am I doing this right?

    Is it a problem with the (ByVal content As Primitive)
    Friday, August 10, 2012 8:36 PM
  • To check the network connection you don't need a "content" variable...

    Change Shared Sub to Function, it will allow to return things...

    Friday, August 10, 2012 9:17 PM
  • What am I doing wrong? It won't display it in Small Basic, even though it is in the "lib" folder, and it has the XML document. Hmm...

    Friday, August 10, 2012 9:33 PM
  • XML Documents are useless if you don't have any XML comments in your extension...

    Change NotInheritable Class into Module. What kind of tutorial have you been following here ^^

    Also Namespaces aren't required, trust me, I have no namespace structure in my extension...
    Friday, August 10, 2012 10:12 PM
  • I really suggest learning C# as there are a lot more tutorials for Small Basic Extensions available. You extension in C# would be:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.SmallBasic.Library;
    
    namespace Net_Ext
    {
        [SmallBasicType]
        public static class NetworkExtension
        {
            public static Primitive GetIsNetworkAvailable()
            {
                if (System.Net.NetworkInformation.NetworkInterface.GetIsNetworkAvailable())
                {
                    return "True";
                }
                else
                {
                    return "False";
                }
            }
        }
    }


    Note that you must: target .Net Framework 3.5, reference the SmallBasicLibrary, adorn with the [SmallBasicType], and use Primitives for all returns and parameters.

    Friday, August 10, 2012 10:17 PM
    Answerer
  • If he dosen't wants to learn C#, he does what he wants, look, my SayPlus! Extension was entirely made in Visual Basic. (3000+ lines of code)

    I followed a nice example I saw in this forum, and it got me started to do it.

    Here it is :

    New Project=>Class Library

    Project=>Add Reference=>Browse=>(C:\Program Files\Microsoft\Small Basic\SmallBasicLibrary.dll)

    Save Project

    Solution Explorer=>Properties=>Compile=>Advanced Compile Options=>Target .Net 3.5 Framework

    Extension code:

    Imports System
    Imports Microsoft.SmallBasic.Library
    
    ''' <summary>
    ''' Simple property test.
    ''' </summary>
    <SmallBasicType()> Public Module TestProperty
        Public my_Property As Primitive
        ''' <summary>
        ''' A Property.
        ''' </summary>
        Public Property PropertyName As Primitive
            Get
                Return my_Property
            End Get
            Set(ByVal value As Primitive)
                my_Property = value
            End Set
        End Property
    
        ''' <summary>
        ''' Addition.
        ''' </summary>
        ''' <param name="Val1">
        ''' First number.
        ''' </param>
        ''' <param name="Val2">
        ''' Second number.
        ''' </param>
        '''<returns>
        ''' Sum.
        ''' </returns>
        Public Function DemoAddition(ByVal Val1 As Primitive, ByVal Val2 As Primitive) As Primitive
            Return (Val1 + Val2)
        End Function
    End Module

    Friday, August 10, 2012 10:24 PM
  • Wow! Thanks for the help and code! I was not following VB.NET tutorial, but instead a C# tutorial I got off the internet that I ran through a translator. :)
    Friday, August 10, 2012 10:40 PM
  • Is C# anything like Java? I know I see a few similarities...
    Friday, August 10, 2012 10:41 PM
  • Pretty much any popular programmation language looks similar, C++ looks much more similar to Java than C# in my opinion...
    Friday, August 10, 2012 10:49 PM
  • C# is a lot like Java in that it has Objects, Generics, etc. (unlike C / C++). However, it has C-like syntax (such as the curly braces, if statements, do... while / for/ while structure, etc.). It is pretty easy to go between the two (I have even heard that MSFT made C# so that VB programmers could learn it quickly and others would not think of them as Basic programmers (nothing against VB... I think it is a pretty complex language) ).

    Anyway, knowing VB, C# is easy to learn. It is more like Java than C / C++ by far, to answer your original question =).

    Friday, August 10, 2012 11:26 PM
    Answerer
  • Thanks for the reply! I may choose to learn C# now! Thanks to your both!

    HAHA! Just finished installing it! :)

    Just wrote my first BEGINNER "Hello World" program! Not to different from VB! Sweet!
    Saturday, August 11, 2012 1:58 AM
  • Great, glad I could be of assistance.
    Saturday, August 11, 2012 3:02 AM
    Answerer
  • :) Did you try out Picnic and the Level Creator?
    Saturday, August 11, 2012 3:04 AM
  • What programming language is the simplest for writing extensions?

    Zock77

    Saturday, August 11, 2012 5:11 PM
    Answerer
  • From what I gathered it seems to be C#, but I sure do love my Visual Basic! :)
    Saturday, August 11, 2012 5:20 PM
  • The choices are VB or C#. 

    They are both almost exactly equivalent in terms of their capability, and only differ in syntax (keywords etc). 

    So which is easier depends on which syntax you find easiest and whatever previous experience you have.  If you are unfamiliar with both, I would choose C# since there are more samples available to get started. 

    If you want a guide to setting up VS 2010 Express C# to write extensions (there are a few settings that need to be set up correctly, e.g. to target .Net 3.5, reference SmallBasicLibrary.xml and allow xml help generation) and download simple sample projects to show syntax, then I have some here.  The getting started guide "Guide to writing extensions" is in the "Other Resource Downloads" section and some simple projects with full C# and VS2010 projects are in the "Demonstration Extensions" section.

    Depending on what you want the extension to do you can get specific help on this forum or the VB/C# forums for more general programming questions.

    Good Luck.

    Saturday, August 11, 2012 5:36 PM
    Moderator
  • Do you have any good tutorials on how to write Small Basic extensions in VB that go step by step? Still learning...

    Saturday, August 11, 2012 8:39 PM
  • No I don't, but am happy to help. 

    The directions by AshkoreDracson ealier in this thread pretty much cover setting it up.  So, if this isn't working we probably need a bit more details about the problem to help further.  I do have a getting started in VB guide similar to the C# one, but it just covers setting up the same very basic extension.

    EDIT

    I gather you can create and compile a working extension, but want help with a specific method in VB - please provide some more details of what the issues are and what you have already.

    Saturday, August 11, 2012 9:23 PM
    Moderator
  • I am generally inquiring on how to make an extentions for future knowledge, in case if a function is not there. I am just having problems between how to accept input and provide output. Thanks you for any help!
    Saturday, August 11, 2012 10:46 PM
  • With Input / Output, all you need to remember is that all parameters and returns MUST be Primitive. If you do that (and use the SmallBasicType and keep everything public static), you will be A-OK.

    Sunday, August 12, 2012 3:12 AM
    Answerer
  • Sounds good!
    Sunday, August 12, 2012 5:19 PM
  • How do I convert A visual basic file to a small basic Dll?

    One thing that is impossible is impossible no matter if it is proven so first.

    Monday, August 27, 2012 4:40 AM
    Answerer
  • It needs to be compiled as an extension - commpiled targeting .Net 3.5 as a class library (dll).  The methods need to be public static and have the SmallBasicType attribute.  Simple example extensions with full project + code and a getting started guide for setting up VS2010 (C# and VB) here (the guide is in Other Resource Downloads section, Guide to writing extensions).
    Monday, August 27, 2012 9:39 AM
    Moderator
  • Sweet! I have VB express 2010. Will that work as well as Visual studios 2010? (I know next to nothing about VS or VB). Thanks for the help!

    One thing that is impossible is impossible no matter if it is proven so first.

    Monday, August 27, 2012 2:27 PM
    Answerer
  • Yes. Once you are done creating the extension, go to to debug>build and it will generate a .dll and .xml in the bin> release folder. Please let me know if you have any more questions. :)

    -Noah J. Buscher "Nothing is Impossible Until Proven Impossible."

    Friday, August 31, 2012 4:26 AM