Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Convert string to integer


  • Please log in to reply
6 replies to this topic

#1 rlcobos

rlcobos

    New Member

  • Members
  • Pip
  • 4 posts

Posted 01 January 2012 - 07:58 PM

Hello It's my first project with Netduino. Really when i start to think about develop with VBNET i was very happy. But now, i am thinking : that is not than good like sound... my last problem is ... i'm trying to convert a single char to integer with : Dim words As String() = linea.Split(","c) Dim HoraInicio As New System.DateTime(1900, 1, 1,ctype(words(0),integer), ctype(words(1),integer), 0) i was trying too with a=cint(words(0)) and return an error..... what am i doing bad?? is too dificoult convert a single string to integer?? sorry for my english. thanks in advance.

#2 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 01 January 2012 - 08:54 PM

Hi rlcobos and welcome to the boards! Could you post a full code, perhaps something would be wrong with the input value. I normally use int.Parse(stringvalue) by the way.
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs

#3 rlcobos

rlcobos

    New Member

  • Members
  • Pip
  • 4 posts

Posted 01 January 2012 - 09:36 PM

Hi, thanks for your quickly reply.... my code is... 'voy separando las lineas, para procesarlas. Try ' Create an instance of StreamReader to read from a file. Using sr As StreamReader = New StreamReader("\SD\datos.txt") Dim linea As String ' Read and display the lines from the file until the end ' of the file is reached. Do linea = sr.ReadLine() Dim words As String() = linea.Split(","c) Debug.Print(func.Valor(words(0).ToString)) Dim HoraInicio As New System.DateTime(1900, 1, 1, func.Valor(words(0).ToString), func.Valor(words(1).ToString), 0) Dim HoraFin As New System.DateTime(1900, 1, 1, func.Valor(words(2).ToString), func.Valor(words(3).ToString), 0) Dim Dia As Integer = func.Valor(words(4).ToString) Insertar(fCol, HoraInicio, HoraFin, Dia) Loop Until linea Is Nothing sr.Close() End Using Catch E As Exception ' Let the user know what went wrong. Debug.Print("The file could not be read:") Debug.Print(E.Message) End Try I have make a new function for convert the string to value is func.valor.... the original code was... Dim HoraInicio As New System.DateTime(1900, 1, 1, cInt(words(0).ToString), cInt(words(1).ToString), 0) and i have try too with... Dim HoraInicio As New System.DateTime(1900, 1, 1, ctype(words(0).ToString,integer), ctype(words(1).ToString,integer), 0) thanks, I supouse , i will ask a lot of question from today...... thanks bye

#4 Joe Griffith

Joe Griffith

    Advanced Member

  • Members
  • PipPipPip
  • 32 posts

Posted 02 January 2012 - 05:14 PM


    Dim Hours As String = "5"
    Dim Minutes As String = "23"
    Dim MyDate As New DateTime(1900, 1, 1, CInt(Hours), CInt(Minutes), 0)
    Debug.Print(MyDate.ToString)


This code works fine for me and produces the expected result:
01/01/1900 05:23:00

So what are the values of words(0) and words(1) and what is the error?



#5 rlcobos

rlcobos

    New Member

  • Members
  • Pip
  • 4 posts

Posted 02 January 2012 - 10:10 PM

Hi, At the first moment, thanks for your time.... I have tryed with try Dim a As String = "10" Dim h As New System.DateTime(1900, 1, 1, CInt(a), CInt(a), 0) catch e as exception Debug.print e.message end try and i have the next in debug... Exception was thrown: System.NotImplementedException I work with DeviceInfo: HAL build info: 4.2.0.0, Netduino Plus (v4.2.0.0 RC3) by Secret Labs LLC OEM Product codes (vendor, model, SKU): 34, 177, 4097 Serial Numbers (module, system): 00000000000000000000000000000000 0000000000000000 Solution Build Info: 4.2.0.0, Netduino Plus (v4.2.0.0 RC3) by Secret Labs LLC AppDomains: Assemblies: mscorlib,4.2.0.0 Microsoft.SPOT.Native,4.2.0.0 Microsoft.SPOT.Hardware,4.2.0.0 Microsoft.SPOT.Net,4.2.0.0 System,4.2.0.0 Microsoft.SPOT.Hardware.SerialPort,4.2.0.0 Microsoft.SPOT.IO,4.2.0.0 System.IO,4.2.0.0 Microsoft.SPOT.Hardware.Usb,4.2.0.0 Microsoft.SPOT.Hardware.PWM,4.2.0.0 SecretLabs.NETMF.Hardware,4.2.0.0 SecretLabs.NETMF.Diagnostics,4.2.0.0 Without SD Card,1.0.0.0 Microsoft.VisualBasic,1.0.0.0 classFecha,1.0.0.0 I have solved this problem with an function in c#, but may be good i can found a better solution.s thanks in advance.

#6 Novice Alex

Novice Alex

    Advanced Member

  • Members
  • PipPipPip
  • 59 posts

Posted 06 February 2012 - 02:24 PM

Hi,

At the first moment, thanks for your time....


I have tryed with


try
Dim a As String = "10"
Dim h As New System.DateTime(1900, 1, 1, CInt(a), CInt(a), 0)
catch e as exception
Debug.print e.message
end try

and i have the next in debug...

Exception was thrown: System.NotImplementedException


I work with

DeviceInfo:
HAL build info: 4.2.0.0, Netduino Plus (v4.2.0.0 RC3) by Secret Labs LLC
OEM Product codes (vendor, model, SKU): 34, 177, 4097
Serial Numbers (module, system):
00000000000000000000000000000000
0000000000000000
Solution Build Info: 4.2.0.0, Netduino Plus (v4.2.0.0 RC3) by Secret Labs LLC
AppDomains:
Assemblies:
mscorlib,4.2.0.0
Microsoft.SPOT.Native,4.2.0.0
Microsoft.SPOT.Hardware,4.2.0.0
Microsoft.SPOT.Net,4.2.0.0
System,4.2.0.0
Microsoft.SPOT.Hardware.SerialPort,4.2.0.0
Microsoft.SPOT.IO,4.2.0.0
System.IO,4.2.0.0
Microsoft.SPOT.Hardware.Usb,4.2.0.0
Microsoft.SPOT.Hardware.PWM,4.2.0.0
SecretLabs.NETMF.Hardware,4.2.0.0
SecretLabs.NETMF.Diagnostics,4.2.0.0
Without SD Card,1.0.0.0
Microsoft.VisualBasic,1.0.0.0
classFecha,1.0.0.0

I have solved this problem with an function in c#, but may be good i can found a better solution.s

thanks in advance.


Just wonder has the 4.2 RC4 solved the VB parse problem.

#7 Stefan

Stefan

    Moderator

  • Members
  • PipPipPip
  • 1965 posts
  • LocationBreda, the Netherlands

Posted 06 February 2012 - 06:04 PM

Just wonder has the 4.2 RC4 solved the VB parse problem.

Just answerred the same question asked by you in this topic:
http://forums.netdui...c3-cint0-fails/

Please try keeping it in one topic :)
"Fact that I'm a moderator doesn't make me an expert in things." Stefan, the eternal newb!
My .NETMF projects: .NETMF Toolbox / Gadgeteer Light / Some PCB designs




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.