Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5961051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:54:39+00:00 2026-05-22T18:54:39+00:00

I have the following functions. When I call getQueryObject(jsonString) It makes the coll parses

  • 0

I have the following functions.
When I call getQueryObject(jsonString) It makes the coll parses the object then returns.
The the assignment to jsonObject is not working. When I start operating on the jsonObject bariable it has the value nothing.
I run Debug and follow the code and the jsonObject in getQueryObject is not failing. and return says it returns the object.

I am new to VB is there something I am missing?

Public Function getInformation(jsonString as string) as string
    Dim jsonObject As JObject
    jsonObject = getQueryObject(jsonString)
    'Operate on object here.
End Function

Private Function getQueryObject(jsonString as string) As JObject
    Dim jsonObject As JObject
    Try
        jsonObject = JObject.Parse(jsonString)

    Catch ex As Exception
        jsonObject = New JObject
    End Try
    Return jsonObject
End Function

A little more information. After I turned on Option strict I started to get an error. Option Strict On disallows implicit conversions from ‘Newtonsoft.Jsont.Linq.Token to Newtonsoft.Json.Linq.JObject’.

I don’s see where I am making any type of conversion.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:54:40+00:00Added an answer on May 22, 2026 at 6:54 pm

    The problem is that you’ve used in the incorrect variable name in the getInformation function.

    Change your code to look like this, instead:

    Public Function GetInformation(jsonString as string) as string
        Dim jsonObj As JObject
        jsonObj = GetQueryObject(jsonString)  // Change the name of this variable
                                              // to match the declaration above it.
        'Operate on object here.
    End Function
    

    Or even simpler, declare and initialize the variable in the same line:

    Public Function GetInformation(jsonString as string) as string
        Dim jsonObj As JObject = GetQueryObject(jsonString)
        'Operate on object here.
    End Function
    

    If you were compiling your code with Option Explicit and Option Strict both turned on, the compiler would have caught this problem for you. Change those settings in your project’s Properties. NEVER write code in VB.NET with Option Explicit turned off. Unexpected things happen.

    What’s happening is that VB.NET is letting you use the jsonObject variable without ever declaring it. The compiler just automagically initializes it to Nothing behind the scenes, which is the default value. It’s a simple enough mistake to make, since that’s the name of the variable in the other method. But it doesn’t work as expected, because it’s not the name of the variable in this method. As long as you haveOption Explicit off, VB.NET doesn’t warn you, and blissfully compiles wrong code.

    (Note that I’m also following the recommended .NET coding convention of CamelCasing all method names. That means they should start with a capital letter, rather than a lower-case letter. Only local variables and parameters should be pascalCased (initial lower-case).)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following two functions: public class MyClass { public void Save<TObject>(TObject object)
Suppose I have a the following in Scala object Foo { var functions: List[String
I'm trying to call c functions from python, I have the following code in
I have the following code in html, I cannot get the Function call back
I have the following C++ function definition, which I am trying to call through
The problem is the following. We have lots of ajax call via $.ajax function.
I have the following code: Some functions: A::A(int i_a) {cout<<int Ctor\n;} //conversion constructor void
Assuming I have the following two JQuery functions - The first, which works: $(#myLink_931).click(function
I have the following dead simple elisp functions; the first removes the fill breaks
I have a class with the following member functions: /// caller pid virtual pid_t

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.