473,378 Members | 1,454 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Convert C# to vb

Al
Can anyone write this code in vb

string highligh(object ytdsales)
{
if (ytdSales.Equals(DBNull.Value)
{
return",<i> No Sales</i>;
}
else
{
if (((int) ytdSales) >1000)
{
return "Good sales"
}
}

basically, I am trying to know how to write functions with
both languages (:
Al
Nov 22 '05 #1
5 1153
I don't have my IDE in front of me, but this should do it:

Function highligh(ByVal ytdasles as Object) As String
If ytdSales.Equals(DbNull.Value) then
return ",<i> No Sales<i>,"
Else If Ctype(ytdSales, Integer) > 1000 then
Return "GoodSales

End If

End Function
"Al" <aa********@yahoo.com> wrote in message
news:01****************************@phx.gbl...
Can anyone write this code in vb

string highligh(object ytdsales)
{
if (ytdSales.Equals(DBNull.Value)
{
return",<i> No Sales</i>;
}
else
{
if (((int) ytdSales) >1000)
{
return "Good sales"
}
}

basically, I am trying to know how to write functions with
both languages (:
Al

Nov 22 '05 #2
Hi Al,

Writting blindly:

Private Function highligh(ytdsales As object) As String
If IsDbNull(ytdsales) Then
return ",<i> No Sales</i>"
Else
If CType(ytdsales, Integer) > 1000 Then
return "Good sales"
End If
End If
End Function

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"Al" <aa********@yahoo.com> wrote in message
news:01****************************@phx.gbl...
Can anyone write this code in vb

string highligh(object ytdsales)
{
if (ytdSales.Equals(DBNull.Value)
{
return",<i> No Sales</i>;
}
else
{
if (((int) ytdSales) >1000)
{
return "Good sales"
}
}

basically, I am trying to know how to write functions with
both languages (:
Al

Nov 22 '05 #3
Cor
Hi Al,

Also written here asuming what is wanted
(I am not sure of the IsDBnull in the other samples will do it and therefore
this sample, and I think this is more VB.net than converted C#)

(I do not like that value boxed in that object I never use that)

Private function highligh(byval ytdsales as object) as string
if Not ytdSales Is Nothing
if Cint(ytdSales) > 1000 then
return "Good sales"
Else
return "Low Sales"
Else
return "No sales"
end if
end function

Just another approach than Bill and Miha

Cor
string highligh(object ytdsales)
{
if (ytdSales.Equals(DBNull.Value)
{
return",<i> No Sales</i>;
}
else
{
if (((int) ytdSales) >1000)
{
return "Good sales"
}
}

basically, I am trying to know how to write functions with
both languages (:
Al

Nov 22 '05 #4
Hi Cor,

You are testing against Nothing (null in C#).
But what about DBNull.Value?

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"Cor" <no*@non.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hi Al,

Also written here asuming what is wanted
(I am not sure of the IsDBnull in the other samples will do it and therefore this sample, and I think this is more VB.net than converted C#)

(I do not like that value boxed in that object I never use that)

Private function highligh(byval ytdsales as object) as string
if Not ytdSales Is Nothing
if Cint(ytdSales) > 1000 then
return "Good sales"
Else
return "Low Sales"
Else
return "No sales"
end if
end function

Just another approach than Bill and Miha

Cor
string highligh(object ytdsales)
{
if (ytdSales.Equals(DBNull.Value)
{
return",<i> No Sales</i>;
}
else
{
if (((int) ytdSales) >1000)
{
return "Good sales"
}
}

basically, I am trying to know how to write functions with
both languages (:
Al


Nov 22 '05 #5
Cor
Hi Miha,

I am not sure of this. But because I have seen that people have a lot of
problems with this I though that it was right to give this example for if it
would give an error there with your example.

When it was an item I just would write
if item<>dbnull.value, that is standard,

Therefore I was not so glad with that object

(I never used your example IsDbValue and did see it only once before)

However if it is a let say a readXML dataset than can it be:
item Is nothing when the node does not exist (I use that, it takes some
extra work before writting the xml set)

item = nothing the node is "" (exist but empty), when I write that in the
vb.language group I get almost direct response from Armin.

But when it is a real database item it can also be
item = dbNull.value and not item Is nothing

Confusing is it not?

Cor.

You are testing against Nothing (null in C#).
But what about DBNull.Value?

Nov 22 '05 #6

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

Similar topics

19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
4
by: Eric Lilja | last post by:
Hello, I've made a templated class Option (a child of the abstract base class OptionBase) that stores an option name (in the form someoption=) and the value belonging to that option. The value is...
7
by: whatluo | last post by:
Hi, all I'm now working on a program which will convert dec number to hex and oct and bin respectively, I've checked the clc but with no luck, so can anybody give me a hit how to make this done...
3
by: Convert TextBox.Text to Int32 Problem | last post by:
Need a little help here. I saw some related posts, so here goes... I have some textboxes which are designed for the user to enter a integer value. In "old school C" we just used the atoi function...
7
by: patang | last post by:
I want to convert amount to words. Is there any funciton available? Example: $230.30 Two Hundred Thirty Dollars and 30/100
4
by: Edwin Knoppert | last post by:
In my code i use the text from a textbox and convert it to a double value. I was using Convert.ToDouble() but i'm used to convert comma to dot. This way i can assure the text is correct. However...
1
by: johnlim20088 | last post by:
Hi, Currently I have 6 web projects located in Visual Source Safe 6.0, as usual, everytime I will open solution file located in my local computer, connected to source safe, then check out/check in...
6
by: Ken Fine | last post by:
This is a basic question. What is the difference between casting and using the Convert.ToXXX methods, from the standpoint of the compiler, in terms of performance, and in other ways? e.g. ...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.