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

  • SEARCH
  • Home
  • 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 6813283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:33:07+00:00 2026-05-26T20:33:07+00:00

After years of doing a little programming on the side (Classic ASP for 12

  • 0

After years of doing a little programming on the side (Classic ASP for 12 years), I’m starting to do a lot more programming, and as a result am teaching myself .net.

I’m attempting to use UrbanAirship’s API to send a test push notification through Apple’s Push Notification Server (APNS). I found this sample code, but am having a hard time implementing it.

I’m receiving the error: BC30188: Declaration expected. Here is the code on this particular line:

req.Credentials = New NetworkCredential("username", "password")

Here is my entire code:

pushvb.aspx

<%@ Page Language="VB" AutoEventWireup="false" src="pushvb_bg.aspx.vb" Inherits="UrbanAirship.uacode" %>

<% Response.write(UrbanAirship.uacode.testing) %>

pushvb_bg.aspx.vb

Imports System   
Imports System.Net  
Imports System.Text  
Imports System.IO  
Imports System.WinForms  

Namespace UrbanAirship  
public partial Class uacode  
    Inherits System.Web.UI.Page  
    Public Const testing As String = "testing..."  
    Dim req As WebRequest = WebRequest.Create("https://go.urbanairship.com/api/push/")  
    Dim postData As String = "{""aps"": {""badge"": ""+1"", ""alert"": ""pushvb"",""sound"": ""default"",""device_tokens"": ""token""}}"  
    req.Credentials = New NetworkCredential("username", "password")  
    req.Method = "POST"  
    Dim byteArray As Byte() = Encoding.UTF8.GetBytes(postData)  
    req.ContentType = "application/json"  
    req.ContentLength = byteArray.Length  
    Dim dataStream As Stream = req.GetRequestStream()  
    dataStream.Write(byteArray, 0, byteArray.Length)  
    dataStream.Close()  
    Dim resp As WebResponse = req.GetResponse() 
    dataStream = resp.GetResponseStream()  
    Dim reader As New StreamReader(dataStream)  
    Dim responseFromServer As String = reader.ReadToEnd()  
    Console.WriteLine(responseFromServer)  
    reader.Close()  
    dataStream.Close()  
    req.Close()  
end Class  
end Namespace  

Any help would be greatly appreciated. Thanks so much for taking the time to look over.

  • 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-26T20:33:08+00:00Added an answer on May 26, 2026 at 8:33 pm

    Well… the answer is quite simple. Outside of Methods only declarations are allowed. You need to create a method in your Class which gets called from you, or is e.g. the Page Load Event.

    Lines with dim and a new are accepted as a declaration, Public Const is also a Declaration.

    The line req.Credentials = New NetworkCredential("username", "password") is the first line in the code which is not a declaration, but an assignment, therfore it is shown in your Error Window.

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

Sidebar

Related Questions

I'm in an introductory comp-sci class (after doing web programming for years) and became
After years of ASP.NET development I'm actually quite surprised that I can't seem to
After developing in VS.NET for many years, I'm starting to do some Xcode development
After 15 years doing UI development, there's very little I look at and think,
After years in embedded programming, I have to develop a Windows app. I dug
I'm working with someone who's looking to get back into programming after several years
I am switching from C to C# after 15 years of doing C. I
I'm finding myself doing more C/C++ code against Win32 lately, and coming from a
I'm just getting into iPhone development after many years doing Java development. I'm looking
I'm just getting back into C++ after a couple of years of doing a

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.