|
Why does this look like VB6 code you tried to convert to VB.NET??
|
|
|
|
|
Dave Kreskowiak wrote: Why does this look like VB6 code you tried to convert to VB.NET?
Because it is just a VB6 module pasted in a VB.NET form. I wouldn't really call that an attempt to convert it...
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
For the purposes of this question, I believe it conveys whta I am trying to gt my program to do. This chunk of code is not my finished product, it is something I am using as a basis for a new class in an even bigger program. It is like looking at a sketch to create a painting.
-Live long and prosper
|
|
|
|
|
Then why did you try to compile the sketch?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
|
It is a chunk of code that I purloined from a tutorial. I am trying to take what is usable and improvise the rest.
-Live long and prosper
|
|
|
|
|
You can't just paste VB6 code in a VB.NET form and expect it to work. The code uses some constructs that doesn't exist in VB any more. VB went through a major change with version 7, becoming an object oriented language using the .NET framework. You are using VB 9 now.
You have to rewrite the code to VB.NET. Here are some pointers:
:: Don't use a structure, use a class.
:: VB.NET has a real Char type, you don't have to use a one character string.
:: Don't use "char" as a member name, as it's now a data type.
:: Declare all variables that you use, and specify a data type for them.
Regarding your error messages; most of the errors are results of the first five errors.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I can not seem to find how to have the code search the print server for ALL network printers and map all of them on a computer. Any ideas on this? I know how to map them one by one, but I want it to map all the printers to the computer that are on the print server.
|
|
|
|
|
Are the printers published in Active Directory?? TechNet: List All Published Printers[^]
If not, and in a domain environment, you'll have to use WMI to query the server computer for it's list of shared printers. You'll need to query WMI's Win32_Share class, where the share's Type is 1. This denotes a share as being a shared print queue. The share name of each printer will be returned in the Win32_Share class' Caption property.
See the TechNet Script Repository[^] for examples using WMI.
|
|
|
|
|
Hello,
I have an older application that uses VB .NET with XCreed Grids and MS Access. I want to convert it so the backend uses SQL Server instead of MS Access.
Do I have to make lot of changes or I can just change the connection string in the Global file?
Anybody has done things like this before?
Thanks,
Ekjon
|
|
|
|
|
Change the connection string, then work through, there could well be SQL differences you need to address, the SQL dialects are not identical
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Is there any nice way to specify that a numeric literal is a byte, other than via silly CByte()? Other numeric types allow one to append a suffix (e.g. s, l, ui, etc.) but I can't find any such suffix for 'byte'.
I guess the unfortunate handling of the 'Not' operator means that a constant byte which equals 1 is not the same thing as a constant integer which equals 1, so the compiler can't simply regard constants as being the smallest type in which they'll fit, but it's still irksome to have to use:
byteVar = byteVar Or CByte(1)
rather than the cleaner:
byteVar = byteVar Or 1
(FWIW, my preferred handling for the 'Not' operator would be for the compiler to regard its output as a signed item large enough to fit the operand, except in the case of 'variable = Not (expression)', in which case its type would be the same as the operand. The result of the 'And' operator would be the type of the smaller operand, so "byteVar = byteVar and not 5" would work without complaint. Such handling would avoid the tricky bug in:
longVar = longVar And Not somethingSmaller
since the sign-extension of the 'Not' result would ensure correct behavior in the upper bits.
|
|
|
|
|
What you're talking about is called a Forced Literal Type. The characters denoting these are:
Literal type char Data Type Example
S Short I=347S
I Integer J=347I
L Long K=347L
D Decimal X=347D
F Single ... you get the idea ...
R Double
US UShort (Unsigned Short)
UI UInteger
UL ULong
C Char
There are no Forced Type Characters for Boolean, Byte, Date, Object, SByte, or String data types, or any composite types.
So, no, there's no easy way to do this, other than defining a constant as a byte:
Public Const MyTrue As Byte = 1
byteVar = byteVar Or MyTrue
|
|
|
|
|
Oh well, thanks. I wonder why there isn't a Forced Type Character for byte? It's not as though "b" is used for anything else.
Is there any way to set "Option Strict" to be a little less strict in VB2005? Some of the squawks are helpful, but some are pretty annoying (particularly given the lack of a byte FTC).
|
|
|
|
|
supercat9 wrote: Is there any way to set "Option Strict" to be a little less strict in VB2005?
No, there's no way to change what is and is not covered under Option Strict. You can, however in a limited way, tell the compiler what to throw an error on, or warning, or no message at all. Just go into the projects properties (My Project), Compile tab, and change the Notification options you want. Implicit conversions are covered by the first three options in the list.
|
|
|
|
|
Hello,
I'd like to know if it's possible to register a filetype/extension, eg "*.xyz" as "New Program File" at installation or program startup. It doesn't have to be linked to a program.
Thanks in advance,
--Zaegra--
|
|
|
|
|
Yes it is possible.
Here[^] is a link to Microsoft's documentation about File Types. And there are pletny of articles on Code Project[^] to get you started.
Hope this helps.
|
|
|
|
|
I've just starting in VB.NET and would like to know if someone could help me out with a minor issue I have.
When I use INPUTBOX(), the textbox is shown on the screen but the text message isn't.
Anyone would know why ?
Again, must be something very easy.. just new to this .NET world
|
|
|
|
|
This question would be better asked in the Mobile Development forum.
Without seeing your code that displays this box, it's impossible to say what the problem is.
|
|
|
|
|
Hello:
I am sending a text stream across a TCPIP nextwork and it works fine. Accept .... when I send the word "[Capture]" across the network. I changed the case of the C at the begining and it works fine. Also change to "{" brackets and works fine. I could just change the brackets or the C to a lower case c but I just am trying to figure out why it fails. The error message is IndexOutOfRangeException.
Thank you in advance
Lee Morin
|
|
|
|
|
There's nothing special about the word "[Capture]" that would cause this. It's probably because of a buffer problem, but with out seeing your failing code and the line that the error occurs on, it's impossible to say.
|
|
|
|
|
Hi i was wondering if anybody could help me figure out how to translate a sentence from english wording to british, i have already figured out how to translate single words but i am having a hard time finding how to translate sentences. If anybody has any ideas, it would be greatly appreciated.
Below i have included my current soure code and the text from my text file.
Source:
Public Class Form1
Structure reader
Dim eng As String
Dim brit As String
End Structure
Dim words(11) As reader
Private Sub wurd_load() Handles MyBase.Load
Dim sr As IO.StreamReader = IO.File.OpenText("words.txt")
For i As Integer = 0 To 11
words(i).eng = sr.ReadLine
words(i).brit = sr.ReadLine
Next
sr.Close()
End Sub
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click
Dim searchword As String, result As Integer
searchword = txt1.Text.ToLower
result = findword(searchword)
If result >= 0 Then
ShowData(result)
Else
MsgBox(searchword & " not in file", 0, "Not Found")
End If
End Sub
Function findword(ByVal searchword As String) As Integer
Dim first, middle, last As Integer
first = 0
last = 11
Do While (first <= last)
middle = CInt(Int((first + last) / 2))
Select Case words(middle).eng.ToLower
Case searchword
Return middle
Case Is > searchword
last = middle - 1
Case Is < searchword
first = middle + 1
End Select
Loop
Return -1
End Function
Sub ShowData(ByVal result As Integer)
'Display the data for the specified state
txt2.Text = words(result).brit
End Sub
End Class
_________________________________________________
Text File:
attic
loft
business suit
lounge suit
elevator
lift
flashlight
torch
french fries
chips
gasoline
petrol
ice cream
ice
megaphone
loud hailer
radio
wireless
sneakers
plimsolls
truck
lorry
zero
naught
________________________________
Please help, i am a beginner.
|
|
|
|
|
darthbane13 wrote: from english wording to british,
Is this a joke ? English to British ? What do you mean ?
Translating sentences is very complex, because rules of grammar change, that is, when you actually have two different languages to translate between.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Basically i want to know to to "Translate" multiple words instead of one from the textbox, like two words or three instead of one.
|
|
|
|