473,811 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why Does this Modular Variable Value Change?

Hi,

The variable _intBlogID changes from -1 to 0 when the Mode_Get method
is called. I don't understand why this happens. I included default
property values, and that didn't help. I wrote and called the method
Properties_Set( ) and that didn't help. Can anyone provide a solution?
Please see code below.

Thanks in advance.

Ryan Penfold, Portsmouth, UK


Option Strict On

Partial Class AddEditBlog
Inherits System.Web.UI.P age

Protected _intMode As PCC.Blogger.Fun ction =
PCC.Blogger.Fun ction.Add
Protected _intBlogID As Integer = -1

''' <summary>
''' Can be "Add" or "Edit"
''' </summary>
<System.Compone ntModel.Default Value(GetType(P CC.Blogger.Func tion),
"Add")Prote cted Property Mode() As PCC.Blogger.Fun ction
Get
If BlogID = -1 Then
_intMode = PCC.Blogger.Fun ction.Add
Else
_intMode = PCC.Blogger.Fun ction.Edit
End If
Return _intMode
End Get
Set(ByVal value As PCC.Blogger.Fun ction)
_intMode = value
End Set
End Property

<System.Compone ntModel.Default Value(-1)Protected Property BlogID()
As Integer
Get
If _intBlogID = -1 Then
Try
_intBlogID = CType(Request.Q ueryString("blo gID"), Integer)
Catch ee As Exception
_intBlogID = -1
End Try
End If
Return _intBlogID
End Get
Set(ByVal value As Integer)
_intBlogID = value
End Set
End Property

Protected Sub Properties_Set( )
_intMode = PCC.Blogger.Fun ction.Add
_intBlogID = -1
End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArg s) Handles Me.Load
If Not IsPostBack Then
Properties_Set( )
End If
lblAddEditBlog. Text = Mode.ToString & " Blog"
End Sub

End Class

Aug 19 '07 #1
5 1513
<ry**********@g mail.comschrieb
Hi,

The variable _intBlogID changes from -1 to 0 when the Mode_Get
method is called. I don't understand why this happens. I included
default property values, and that didn't help. I wrote and called
the method Properties_Set( ) and that didn't help. Can anyone provide
a solution? Please see code below.
"Add")Prote cted Property Mode() As PCC.Blogger.Fun ction
Get
You are calling the BlogID property here:
If BlogID = -1 Then
<System.Compone ntModel.Default Value(-1)Protected Property
BlogID() As Integer
Get
If _intBlogID = -1 Then
Try
And here you change the value, probably to 0:
_intBlogID = CType(Request.Q ueryString("blo gID"), Integer)


Armin
Aug 19 '07 #2
Hi Armin,

The value Request.QuerySt ring("blogID") is equal to "", so an
exception should be thrown / caught.

I cannot set an initial value of BlogID to -1, it's always worked
before, I can't think what I'm doing different.

Ryan

Aug 19 '07 #3
<ry**********@g mail.comschrieb
Hi Armin,

The value Request.QuerySt ring("blogID") is equal to "", so an
exception should be thrown / caught.

I cannot set an initial value of BlogID to -1, it's always worked
before, I can't think what I'm doing different.

I didn't know the value of Querystring, that's why I assumed that it returns
0. Other than that, I don't see any code that can set it to 0.
Armin

Aug 19 '07 #4
in the case of a null ( Nothing ) ctype returns a 0 so i guess the
request.queryst ring returns a null value instead of a "" empty string wich
indeed wil raise an error by ctype

proofe ?? copy paste this under a button

msgbox (ctype(nothing, integer))

you wil see that it returns 0

so change your property code to this ( copy pastable )

<System.Compone ntModel.Default Value(-1)Protected Property BlogID() As
Integer

Get

If _intBlogID = -1 Then

If Not Integer.TryPars e(Request.Query String("blogID" ), _intBlogID) Then

_intBlogID = -1

End If

End If

Return _intBlogID

End Get

Set(ByVal value As Integer)

_intBlogID = value

End Set

End Property

and it should work as you expected

HTH

Michel Posseth


"Armin Zingler" <az*******@free net.deschreef in bericht
news:e5******** ******@TK2MSFTN GP06.phx.gbl...
<ry**********@g mail.comschrieb
>Hi Armin,

The value Request.QuerySt ring("blogID") is equal to "", so an
exception should be thrown / caught.

I cannot set an initial value of BlogID to -1, it's always worked
before, I can't think what I'm doing different.


I didn't know the value of Querystring, that's why I assumed that it
returns
0. Other than that, I don't see any code that can set it to 0.
Armin

Aug 19 '07 #5
Nice one Michel, does the job!

-Ryan
Aug 19 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2563
by: lawrence | last post by:
I'm learning Javascript. I downloaded a script for study. Please tell me how the variable "loop" can have scope in the first function when it is altered in the second function? It is not defined in global space, therefore it is not a global variable, yes? Even if it was global, how would it get from one function to another? In PHP variables are copied by value. Are they copied by reference in Javascript? <SCRIPT LANGUAGE="JavaScript">
6
8099
by: lkrubner | last post by:
I'm offering users the ability to type weblog posts into a form and post them. They type the text into a TEXTAREA which is on a form. The form, when submitted, hits a PHP script. Before it is submitted, while they are typing, I'm trying to offer them some common word processing functions. I want to implement unlimited undo and redo for the textarea. I've set the textarea to onChange="addToArrayOfPastWork()"; My undo button gives me...
26
4862
by: I_AM_DON_AND_YOU? | last post by:
This is the scenario: I have a VB.Net project comprising of a few Forms. On Form1 I have more than 20 buttons. There is a very lenghty code written in click event of each and every button. Right now I haven't used any sub procedure. I mean to say I am writing the code directly in the click event. So it's become very lengthy and therefore to figure out some problem or make any changes I have to scroll at lot. Also in addition to click...
8
3627
by: QQ | last post by:
SpreadsheetCell(const string& initialValue); I don't understand what & means here? Thank you very much! A C++ beginner
2
2355
by: lotus | last post by:
HI All.. I'm realtively new to C#. I have MainForm which includes Parent usercontol, and this parent usercontrol also contains child usercontrol. MainForm --> Parent usercontrol --> child usercontrol Parent usercontol has one button to change the child usercontorl's variable.
61
3785
by: Marty | last post by:
I am new to C# and to structs so this could be easy or just not possible. I have a struct defined called Branch If I use Branch myBranch = new Branch(i); // everything works If I use Branch (myBranch + x) = new Branch(i); // it doesn't x is a loop iterator, i is an int for the constructor to define an array. What am I doing wrong here.
52
3243
by: Julie | last post by:
I'm supporting an application at work. Below are some code segments that I can't understand how they work. First let me say, I would never code this standard. I'm just really creeped out that it works. Here's the setup. I have a function, called GetEmployeeCertifications, that is going to make a call to a SQL DB and return a result set. This module calls another function, called FillParameters, to determine if SQL parameters need to...
51
3992
by: Tony Sinclair | last post by:
I'm just learning C#. I'm writing a program (using Visual C# 2005 on WinXP) to combine several files into one (HKSplit is a popular freeware program that does this, but it requires all input and output to be within one directory, and I want to be able to combine files from different directories into another directory of my choice). My program seems to work fine, but I'm wondering about this loop: for (int i = 0; i < numFiles; i++)
22
2543
by: Cogito | last post by:
For the first time, I'm attempting to write a small Javascript program using one on the online reference sites. I need some confirmation as to the behaviour of the break statement. In the following code: for ( row = 0 ; row <= 7 ; row++ ) A <---- { for ( col = 0 ; col <=7 ; col++ ) B <---- {
0
9731
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10405
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4342
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.