[Gambas-user] Convert string to integer
Bruce
bbruen at ...2308...
Sun Jan 26 08:55:18 CET 2014
On Sun, 2014-01-26 at 08:35 +0100, Dirk wrote:
> Hi,
>
> I'm having a problem with Convert string to integer
>
>
> where is my mistake? I get error message:
> Type incompatibility expected integer, instead get string
>
>
> Public Sub MySock_Read()
>
> '************************************************************************************************
>
> ''************************************************************************************************
>
> '''************************************************************************************************
> ' When some data arrives from the remote
> ' part of the socket, "DataAvailable" event
> ' is raised
> '****************************************
> Dim rx, rx2, rxtmp As String
> Dim pattern, result, s, element As String
> Dim i, ii, iii, frequenz, istZeile As Integer
> ' DIM reg AS Regexp
>
> Dim el, text, dxde, txcall, dxcall, dxtxt, utc, loca, tmpstr, NewDXZ,
> DXCall_anfang, toall As String
> Dim band As String
> ' Dim qrg_i As Integer
> Dim qrg_i As Variant
> Dim qrg As String
> Dim dxprafix As String
> Dim dxcall_tmp As String
> Dim trenner As String
> Dim mh As String
> Dim dxland As String
> Dim flagge As String
> Dim sa, zeile, z As String[]
> Dim wp As Integer
> Dim wpa As String[]
> Dim wpi As Integer
> Dim dxcall_lng As Integer
>
> stunde = 0
> minu = 0
> sekunde = 0
>
> If MySock.Status = Net.Connected Then
> Read #MySock, rx, Lof(MySock)
> rx2 = rx
>
> If Mid$(rx, 1, 6) = "To ALL" Then
> Textedit1.richText = Textedit1.richText & "<font color=red>"
> toall = "ok"
>
> End If
> If Mid$(rx, 1, 3) = "WWV" Then
> TextEdit1.richText = TextEdit1.richText & "<font color=blue>"
> toall = "ok"
> End If
> If Mid$(rx, 1, 3) = "WCY" Then
> TextEdit1.richText = TextEdit1.richText & "<font color=blue>"
> toall = "ok"
> End If
>
> If Mid$(rx, 1, 5) = "DX de" Then
> '_____________________________________________
> '_ DX Meldung läuft ein _
> '_____________________________________________
>
> dxde = Mid$(rx, 1, 5)
> rx = Trim(Replace$(rx, "DX de ", ""))
> i = InStr(rx, " ")
> txcall = Mid$(rx, 1, i)
> rx = Trim(Replace$(rx, txcall & " ", ""))
> qrg = Mid$(rx, 1, InStr(rx, " "))
> rx = Trim(Replace$(rx, qrg & " ", ""))
> dxcall = Mid$(rx, 1, InStr(rx, " "))
> rx = Trim(Replace$(rx, dxcall & " ", ""))
> ' . . . . . . . . . .
> qrg = Trim(qrg)
> qrg_i = CInteger(qrg) ' <<<== Here is Error
>
>
> If qrg_i < 440000 And qrg_i > 430000 Then
> mh430 = machmaupdatestr(mh430, dxcall, qrg)
> wpa = Split(mh430, " ")
> nr430 = wpa.length - 1
> ' wp = machma_buttonw(mh430)
>
> machma_balken()
> End If
> If qrg_i < 146000 A...
>
>
>
>
> --
> Dirk
>
>
from the considerable amount of code provided and the unfortunate bit
ellided (see I told you I was getting the hang of this ... thing)
Probably grg isn't convertible?
qrg = Trim(qrg)
Try grg_i=CInteger(grg)
If Error then Error Subst("&1 won't convert",grg)
qrg_i = CInteger(qrg) ' <<<== Here is Error
might help.
Don't confuse data with expected types. (And by dog, haven't we all gone
there!)
hth
B
More information about the User
mailing list