473,756 Members | 3,686 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert WebControls.Uni t to String

Hello,

In a custom control property I have the following:

If CStr(ViewState( "InfoWidth" )) Is Nothing Then ...

I am getting the error:

Conversion from type 'Unit' to type 'String' is not valid.

Can someone tell me how can I convert the InfoWidth (Type =
WebControls.Uni t) to a string?

Thanks,
Miguel

Oct 13 '06 #1
1 4334
If you are checking against null, you don't need to convert anything,
simply:

if ViewState("Info Width") is nothing Then
...
end if

will work.

That's actually the right way to do it, check for null BEFORE trying to
convert anything, otherwise you'll get nullreferenceex ceptions.

Once you are sure it isn't null, use it's ToString() method. This is what it
looks like:

Public Function ToString(ByVal formatProvider As IFormatProvider ) As String
Dim text1 As String
If Me.IsEmpty Then
Return String.Empty
End If
If (Me.type = UnitType.Pixel) Then
text1 = CInt(Me.value). ToString(format Provider)
Else
text1 = CSng(Me.value). ToString(format Provider)
End If
Return (text1 & Unit.GetStringF romType(Me.type ))
End Function


--
http://www.openmymind.net/
http://www.codebetter.com/
"shapper" <md*****@gmail. comwrote in message
news:11******** **************@ f16g2000cwb.goo glegroups.com.. .
Hello,

In a custom control property I have the following:

If CStr(ViewState( "InfoWidth" )) Is Nothing Then ...

I am getting the error:

Conversion from type 'Unit' to type 'String' is not valid.

Can someone tell me how can I convert the InfoWidth (Type =
WebControls.Uni t) to a string?

Thanks,
Miguel

Oct 13 '06 #2

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

Similar topics

1
4486
by: Swarup | last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling it into a byte arry. Now i have to convert it into a string to store it in the database. I use System.Text.UnicodeEncoding enc = new System.Text.UnicodeEncoding(); now i am using enc.GetString(value) and the value retured is one byte less if the size of the byte array is Odd. In case of files having even number of bytes, the convertion is happening correctly and...
8
2051
by: FrzzMan | last post by:
How to convert back a string that have converted to byte using System.Text.Encoding.UTF8.GetBytes() string StringData = "This is a string"; byte ConvertedString = System.Text.Encoding.UTF8.GetBytes(StringData); Now, how can I convert ConvertedString to "This is a string" string again?
1
366
by: Ken Varn | last post by:
This is probably a common question, but bear with me. I am new to this stuff. I want to convert a Unit Width and/or Height to an actual pixel Int32 Width and Height. I was just using the Value attribute of the Unit, but was not sure if this is how it should be done. Not knowing what would happen if someone specified % or other Unit types. -- -----------------------------------
5
260055
by: moondaddy | last post by:
How do I get the string representation of an int? for example int var1 = 2; string var2 = var1.ToString; I'm wanting var2 to be "2" I get the compile error: Error 1 Cannot convert method group 'ToString' to non-delegate type
3
3134
by: bussiere maillist | last post by:
i've got a very long string and i wanted to convert it in binary like string = """Monty Python, or The Pythons, is the collective name of the creators of Monty Python's Flying Circus, a British television comedy sketch show that first aired on the BBC on October 5, 1969. A total of 45 episodes were made over four series. However, the Python phenomenon was much greater, spawning stage tours, a musical, four films, numerous albums, and...
2
94059
by: Joah Senegal | last post by:
Hello I need to convert a chat to a string... but I don't know how to do this. i;ve searched the internet but I've only find some code to convert char * to string or char to string.... but I just need char to string. Anyone knows how to do this ? thanks!!!!
8
6620
by: =?Utf-8?B?UmljYXJkbyBRdWludGFuaWxsYQ==?= | last post by:
i need to convert data from string to nibble wich (nibble is a four bits representation) As example i have the following code string data1 = "12345678"; so ¿how can i convert this data (numbers) to a nibble representation? thanks for any idea
2
2532
by: =?Utf-8?B?SmR1YW4=?= | last post by:
objImage.Height.Value
3
19870
by: mamul | last post by:
Hi please some one can help me. how to convert char * to string? i have take char *argv from command line and want to pass to a function as string object(string str) i want to first convert argv to string object of type str, then pass to function(). please help me how to convert this
0
9275
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
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9713
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
8713
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
7248
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
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
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...
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.